/* The glyph wall, shared by the landing page and /glyphs. glyph-wall.js binds
   to the parts marked data-gw and sets data-gw-mode on the root. In
   "embedded" mode the wall is a window of fixed height that the ruler, find,
   the filters and the arrow keys move, while a wheel or a swipe over it
   scrolls the page. In "page" mode the page scrolls through the wall, and
   the inspector and the ruler stay in view below the header. The tokens
   come from site.css. */
.gw {
  --gw-top: var(--head);
  --gw-edge: clamp(16px, 3vw, 48px);
  --gw-pad: clamp(32px, 4vw, 56px);
  --gw-gap: clamp(24px, 2.3vw, 32px);
  --gw-ruler: 128px;
  --gw-face: var(--sans);
  --gw-w: 400;
  --gw-style: normal;
  --gw-rule: color-mix(in srgb, var(--score) 30%, transparent);
  display: grid;
  grid-template-columns: minmax(300px, 3fr) minmax(0, 7fr);
  background: var(--sheet);
  overflow-anchor: none;
}

/* the inspector and its controls */
.gw-side { min-width: 0; }
.gw-side-in { container: gwside / inline-size; display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: var(--gw-gap); padding: var(--gw-pad) var(--gw-edge); }
.gw-insp { display: grid; gap: 12px; margin: 0; }
.gw-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 16px; }
.gw-svg { display: block; width: 100%; height: auto; aspect-ratio: 5 / 4; background: var(--panel); border-radius: 8px; }
.gw-cap { display: grid; gap: 4px; min-width: 0; }
/* the name always holds two lines and the facts one, so moving between glyphs never shifts what sits below */
.gw-name { min-height: 2.6em; font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.gw-facts { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 0.8125rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.gw-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.gw-acts .btn { text-decoration: none; color: var(--ink); }

/* The glyph name, HTML, CSS and UTF-8, two to a row; each value copies
   itself. A value stays on one line, so the list keeps one height. */
.gw-more { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; margin: 0; font-size: 0.8125rem; }
.gw-more > div { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.gw-more dt { flex: none; width: 3.25rem; color: var(--ink-2); }
.gw-more dd { display: flex; margin: 0; min-width: 0; }
.gw-val { min-width: 0; max-width: 100%; padding: 2px 6px; border: 0; border-radius: 4px; background: var(--panel); color: var(--ink); font-family: var(--mono); font-size: 0.75rem; line-height: 1.5; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: copy; }
.gw-val:hover { background: color-mix(in srgb, var(--ink) 10%, var(--panel)); }
.gw-val[data-flash] { background: var(--ink); color: var(--sheet); }

/* the glyph in each member; the member the wall is set in is the ink tile */
.gw-members { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
.gw-members button { display: grid; justify-items: center; gap: 2px; min-width: 0; padding: 8px 2px 7px; border: 0; border-radius: 6px; background: var(--panel); color: var(--ink); font: inherit; cursor: pointer; transition: background-color 0.12s ease; }
.gw-members button:hover { background: color-mix(in srgb, var(--ink) 8%, var(--panel)); }
.gw-members button[aria-pressed="true"] { background: var(--ink); color: var(--sheet); }
.gw-members b { display: block; height: 2.25rem; font-size: 1.625rem; line-height: 2.25rem; font-weight: var(--gw-w); font-style: var(--gw-style); white-space: nowrap; }
.gw-members span { font-size: 0.6875rem; line-height: 1.2; color: var(--ink-2); }
.gw-members button[aria-pressed="true"] span { color: color-mix(in srgb, var(--sheet) 72%, transparent); }
.gw-members .is-none b { color: color-mix(in srgb, currentColor 28%, transparent); }

.gw-controls { display: grid; gap: var(--sp-4, 16px); min-width: 0; }
.gw-tune { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.gw-weight { flex: 1 1 200px; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) 3ch; align-items: center; gap: 12px; font-size: 0.8125rem; color: var(--ink-2); }
.gw-weight output { text-align: right; color: var(--ink); font-family: var(--mono); font-variant-numeric: tabular-nums; }
.gw-size, .gw-style { flex: none; }
.gw-sets { display: flex; flex: none; gap: 16px; }
.gw-size button, .gw-style button { padding: 4px 9px; font-size: 0.8125rem; }
.gw-groups { justify-self: start; }
.gw-find input { width: 100%; padding: 9px 12px; border: 0; border-radius: 6px; background: var(--panel); color: var(--ink); font: inherit; font-size: 0.875rem; }
.gw-find input::placeholder { color: var(--ink-2); }
.gw-note { margin: -6px 0 0; min-height: 1.25rem; max-width: none; font-size: 0.8125rem; line-height: 1.25rem; color: var(--ink-2); }
.gw-note.is-miss { color: var(--ink); }

/* The wall: rows at their own offsets in a container as tall as the whole
   wall. Each row is one ruled baseline. A cell's empty inline block, as tall
   as --base, puts the glyph's baseline on that rule whatever the font's
   vertical metrics. */
.gw-main { position: relative; min-width: 0; }
.gw-wall { min-width: 0; outline: none; }
.gw-rows { position: relative; contain: size layout style; font-family: var(--gw-face); font-weight: var(--gw-w); font-style: var(--gw-style); color: var(--ink); user-select: none; -webkit-user-select: none; }
.gw-row { position: absolute; left: 0; right: 0; display: grid; grid-template-columns: repeat(var(--cols), var(--cell)); height: var(--cell); padding-left: var(--gutter);
  background: linear-gradient(var(--gw-rule), var(--gw-rule)) var(--gutter) var(--base) / calc(100% - var(--gutter)) 1px no-repeat; }
.gw-c { --gw-fill: transparent; height: var(--cell); font-size: calc(var(--cell) * 0.5); line-height: 0; text-align: center; white-space: nowrap; cursor: pointer;
  background: linear-gradient(var(--gw-fill), var(--gw-fill)) 2px 2px / calc(100% - 4px) calc(100% - 4px) no-repeat; }
.gw-c::before, .gw-cp::before { content: ""; display: inline-block; height: var(--base); }
.gw-c:hover { --gw-fill: var(--panel); }
.gw-c.is-sel { --gw-fill: var(--ink); color: var(--sheet); }
.gw-wall:focus-visible .gw-c.is-sel { --gw-fill: var(--cut); color: var(--on-accent); }
.gw-cp { position: absolute; top: 0; left: 14px; font-family: var(--mono); font-size: 10px; font-weight: 400; line-height: 0; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.gw-ruler { display: block; cursor: ns-resize; touch-action: none; user-select: none; -webkit-user-select: none; }
.gw-mini { display: none; }

/* Embedded: the wall is a window with the ruler down its right edge. Its
   overflow is hidden, so a wheel or a swipe over it scrolls the page and
   never stops there; the script moves the window. */
.gw[data-gw-mode="embedded"] .gw-main { min-height: clamp(560px, 80vh, 880px); }
.gw[data-gw-mode="embedded"] .gw-wall { position: absolute; inset: 0 var(--gw-ruler) 0 0; overflow-y: hidden; overscroll-behavior: auto; }
.gw[data-gw-mode="embedded"] .gw-wall:focus-visible { box-shadow: inset 0 0 0 2px var(--ink); }
.gw[data-gw-mode="embedded"] .gw-note:empty { display: none; }
.gw[data-gw-mode="embedded"] .gw-note { margin: 0; min-height: 0; }
.gw[data-gw-mode="embedded"] .gw-ruler { position: absolute; top: 0; right: 0; bottom: 0; width: var(--gw-ruler); height: 100%; }
@media (max-width: 1100px) {
  .gw[data-gw-mode="embedded"] { grid-template-columns: minmax(0, 1fr); }
  .gw[data-gw-mode="embedded"] .gw-side-in { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .gw[data-gw-mode="embedded"] .gw-side-in > :is(h2, .gw-head) { grid-column: 1 / -1; }
  .gw[data-gw-mode="embedded"] .gw-main { min-height: 72vh; }
}
@media (max-width: 640px) {
  .gw[data-gw-mode="embedded"] { --gw-ruler: 28px; }
  .gw[data-gw-mode="embedded"] .gw-side-in { grid-template-columns: minmax(0, 1fr); }
}

/* Page: the window scrolls through the wall. On a wide screen the inspector
   column and the ruler stay under the header while the rows go by, and both
   stop at the end of the wall. */
.gw[data-gw-mode="page"] { padding-bottom: clamp(56px, 6.67vw, 96px); }
.gw[data-gw-mode="page"] .gw-side-in { position: sticky; top: var(--gw-top); gap: 12px; padding: 12px var(--gw-edge) 24px; }
.gw[data-gw-mode="page"] .gw-side-in[data-loose] { position: static; }
.gw[data-gw-mode="page"] .gw-controls { position: relative; gap: 12px; margin-top: 6px; }
/* the note takes the column's bottom padding, so a miss or a count moves nothing */
.gw[data-gw-mode="page"] .gw-note { position: absolute; top: 100%; left: 0; right: 0; margin: 2px 0 0; min-height: 0; }
.gw[data-gw-mode="page"] .gw-main { display: grid; grid-template-columns: minmax(0, 1fr) var(--gw-ruler); align-items: start; }
.gw[data-gw-mode="page"] .gw-wall { grid-area: 1 / 1; padding-top: 12px; }
.gw[data-gw-mode="page"] .gw-ruler { grid-area: 1 / 2; position: sticky; top: var(--gw-top); width: var(--gw-ruler); height: calc(100dvh - var(--gw-top)); }

/* Narrower: the inspector sits above the wall, the drawing beside its facts.
   A bar at the top of the wall holds the selection under the header once the
   drawing is out of view; its slot stays empty until then. */
@media (max-width: 859px) {
  .gw[data-gw-mode="page"] { grid-template-columns: minmax(0, 1fr); }
  .gw[data-gw-mode="page"] .gw-side-in { position: static; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "svg cap" "svg more" "svg tiles" "ctl ctl"; grid-template-rows: auto auto 1fr auto; align-items: start; column-gap: var(--gw-gap); padding: 0 var(--gw-edge) 4px; }
  .gw[data-gw-mode="page"] .gw-svg { grid-area: svg; }
  .gw[data-gw-mode="page"] .gw-cap { grid-area: cap; }
  .gw[data-gw-mode="page"] .gw-more { grid-area: more; }
  .gw[data-gw-mode="page"] .gw-members { grid-area: tiles; }
  .gw[data-gw-mode="page"] .gw-controls { grid-area: ctl; margin-top: 4px; }
  .gw[data-gw-mode="page"] .gw-note { position: static; margin-top: -4px; min-height: 1.25rem; }
  .gw[data-gw-mode="page"] .gw-wall { padding-top: 0; }
  .gw[data-gw-mode="page"] .gw-mini { display: block; position: sticky; top: var(--gw-top); z-index: 4; height: 52px; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.15s ease, visibility 0.15s; }
  .gw[data-gw-mode="page"] .gw-mini[data-on] { opacity: 1; visibility: visible; pointer-events: auto; }
  .gw-mini-in { display: flex; align-items: center; gap: 12px; width: 100%; height: 100%; padding: 0 12px 0 var(--gw-edge); border: 0; background: color-mix(in srgb, var(--ink) 4%, var(--sheet)); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
  .gw-mini-in b { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 6px; background: var(--ink); color: var(--sheet); font-family: var(--gw-face); font-size: 1.375rem; font-weight: var(--gw-w); font-style: var(--gw-style); line-height: 1; overflow: hidden; }
  .gw-mini-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.875rem; font-weight: 600; }
  .gw-mini-u { flex: none; font-family: var(--mono); font-size: 0.75rem; color: var(--ink-2); }
}
@media (max-width: 639px) { .gw[data-gw-mode="page"] { --gw-ruler: 28px; } }
@media (max-width: 559px) {
  .gw[data-gw-mode="page"] .gw-side-in { grid-template-columns: minmax(0, 1fr); grid-template-areas: "svg" "cap" "more" "tiles" "ctl"; grid-template-rows: none; gap: 14px; }
  .gw[data-gw-mode="page"] .gw-svg { aspect-ratio: 16 / 10; }
}
/* a narrow inspector column: smaller facts and tiles, each detail under its
   label, and the filters without their counts, so the column fits a laptop screen */
@container gwside (max-width: 339px) {
  .gw-facts { font-size: 0.75rem; }
  .gw-more > div { display: grid; gap: 1px; }
  .gw-more dt { width: auto; font-size: 0.6875rem; }
  .gw-members b { height: 1.875rem; font-size: 1.375rem; line-height: 1.875rem; }
  .gw-groups button span { display: none; }
}
/* narrower still: the weight slider takes the whole row and the sizes go under it */
@container gwside (max-width: 279px) {
  .gw-tune { flex-wrap: wrap; gap: 10px; }
  .gw-weight { flex-basis: 100%; }
}
/* on a touch screen each copy value takes taps over 44px (site.css), so the values stop clipping, and the values and the controls take that room */
@media (pointer: coarse) { .gw-val { overflow: visible; } .gw-more { row-gap: 22px; } .gw[data-gw-mode] .gw-controls { row-gap: 18px; } }
@media (prefers-reduced-motion: reduce) { .gw-members button, .gw[data-gw-mode="page"] .gw-mini { transition: none; } }
