/* The typeface picker of an editor: one card alone on white, a single tomato accent. */
:root {
  --fondo: #ffffff;
  --carta: #ffffff;
  --bordo: #e7e7ea;
  --tinta: #f4f4f6;          /* the field, the segments, the row under the pointer */
  --testo: #121214;
  --testo-2: #5d5d66;
  --testo-3: #a1a1aa;
  --accento: #e8462e;        /* the single accent: the tick, the search caret, the light on the edge */
  --ombra: 18, 18, 24;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { font-size: clamp(10px, min(3.6vw, 3.05vh), 17px); }
body {
  background: var(--fondo);
  color: var(--testo);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

.stage { height: 100vh; display: grid; place-items: center; padding: 2vh 4vw; }

/* the card: a body, a 1px edge that catches light at the top, three soft shadows; its height is fixed, so the
   panel opens inside it and nothing below moves */
.card {
  position: relative;
  width: min(22.5em, 92vw);
  height: 28.6em;
  padding: 1.15em 1.3em 1.2em;
  border-radius: 1.5em;
  background: var(--carta);
  box-shadow:
    0 1px 1px rgba(var(--ombra), .05),
    0 6px 14px -6px rgba(var(--ombra), .10),
    0 24px 48px -24px rgba(var(--ombra), .22);
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  isolation: isolate;
  overflow: clip;
}
.card__edge {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none; z-index: 5;
  padding: 1px;
  background: linear-gradient(180deg, rgba(232, 70, 46, .28), var(--bordo) 20%, var(--bordo) 82%, #dedee2);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}
.card__glow {
  position: absolute; top: 0; left: 0; width: 38%; height: 1px; z-index: 6; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(232, 70, 46, .9), transparent);
  opacity: 0;
}

.head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .95em; }
.head__title { font-size: .98em; font-weight: 650; letter-spacing: -.02em; }
.head__meta { font-size: .72em; font-weight: 540; color: var(--testo-3); }

.label { display: block; font-size: .68em; font-weight: 600; color: var(--testo-2); letter-spacing: .01em; margin-bottom: .45em; }

/* the field: the typeface name written in itself, its category, the chevron that turns half a turn */
.field {
  position: relative; z-index: 4;
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; column-gap: .6em;
  height: 3em; padding: 0 .85em 0 1em; width: 100%;
  border-radius: .85em;
  background: var(--tinta);
  box-shadow: inset 0 0 0 1px rgba(var(--ombra), .06);
  text-align: left;
  transition: box-shadow .25s ease, background-color .25s ease;
}
.field:focus-visible, .field.is-open { box-shadow: inset 0 0 0 1px rgba(var(--ombra), .16), 0 0 0 3px rgba(232, 70, 46, .14); background: #fff; }
.field__name { font-size: 1.08em; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: .1em 0; }
.field__cat { font-size: .66em; font-weight: 560; color: var(--testo-3); letter-spacing: .02em; }
.field__chev { width: 1em; height: 1em; fill: none; stroke: var(--testo-2); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* the preview: one real sentence, set in the chosen typeface and weight */
.preview {
  position: relative;
  margin-top: .9em;
  padding: .85em 1em .9em;
  border-radius: 1em;
  background: linear-gradient(180deg, #fbfbfc, #f7f7f9);
  box-shadow: inset 0 0 0 1px rgba(var(--ombra), .05);
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}
.preview__label { font-size: .62em; font-weight: 600; color: var(--testo-3); letter-spacing: .02em; }
.preview__text {
  align-self: center;
  font-size: 2em; line-height: 1.08; letter-spacing: -.015em;
  overflow-wrap: break-word;
}
.preview__text .w { display: inline-block; white-space: nowrap; }
.preview__text .l { display: inline-block; will-change: transform; }

/* the weight: three segments and a pill that slides */
.weight { margin-top: .9em; }
.seg {
  position: relative; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  height: 2.6em; padding: .22em; border-radius: .85em; background: var(--tinta);
  box-shadow: inset 0 0 0 1px rgba(var(--ombra), .05);
}
.seg__pill {
  position: absolute; top: .22em; bottom: .22em; left: 0; width: 0; border-radius: .66em; background: #fff;
  box-shadow: 0 1px 2px rgba(var(--ombra), .10), 0 4px 10px -6px rgba(var(--ombra), .35);
}
.seg__opt {
  position: relative; z-index: 1; display: grid; place-items: center; min-width: 0;
  border-radius: .66em; font-size: .78em; color: var(--testo-2);
  transition: color .25s ease;
}
.seg__opt span { line-height: 1; white-space: nowrap; }
.seg__opt[data-w="300"] span { font-weight: 300; }
.seg__opt[data-w="400"] span { font-weight: 450; }
.seg__opt[data-w="700"] span { font-weight: 700; }
.seg__opt[aria-checked="true"] { color: var(--testo); }
.seg__opt:focus-visible { outline: 2px solid rgba(232, 70, 46, .45); outline-offset: -2px; }

/* the panel: opens under the field, over the preview and the weight, inside the card */
.panel {
  position: absolute; z-index: 3;
  left: 1.1em; right: 1.1em; bottom: 1.1em;
  top: 0; /* set from the field in the script */
  border-radius: 1em; background: #fff;
  box-shadow:
    0 0 0 1px rgba(var(--ombra), .07),
    0 10px 24px -10px rgba(var(--ombra), .28),
    0 30px 60px -30px rgba(var(--ombra), .35);
  padding: .55em;
  display: grid; grid-template-rows: auto minmax(0, 1fr); row-gap: .4em;
  transform-origin: 50% 0;
  visibility: hidden; opacity: 0;
}
.search {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: .5em;
  height: 2.4em; padding: 0 .75em; border-radius: .7em; background: var(--tinta);
}
.search svg { width: .95em; height: .95em; fill: none; stroke: var(--testo-3); stroke-width: 1.6; stroke-linecap: round; }
.search input {
  border: 0; outline: 0; background: none; min-width: 0; width: 100%;
  font: inherit; font-size: .8em; color: var(--testo); caret-color: var(--accento);
}
.search input::placeholder { color: var(--testo-3); }

.list { position: relative; overflow: hidden; }
.list__pill {
  position: absolute; left: 0; right: 0; top: 0; height: 0; border-radius: .6em; background: var(--tinta);
  opacity: 0; pointer-events: none;
}
.row {
  position: relative; z-index: 1; overflow: hidden;
  display: grid; grid-template-columns: minmax(0, 1fr) auto 1.1em; align-items: center; column-gap: .6em;
  width: 100%; height: 2.15em; padding: 0 .7em; border-radius: .6em; text-align: left;
}
.row__name { font-size: 1.02em; line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: .12em 0; }
.row__cat { font-size: .64em; font-weight: 560; color: var(--testo-3); letter-spacing: .02em; }
.row__tick { width: 1.1em; height: 1.1em; fill: none; stroke: var(--accento); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.row__tick path { stroke-dasharray: 1; stroke-dashoffset: 1; }
.row.is-on .row__tick path { stroke-dashoffset: 0; }
.empty { position: absolute; left: 0; right: 0; bottom: 45%; text-align: center; font-size: .74em; color: var(--testo-3); opacity: 0; pointer-events: none; }

@media (hover: hover) {
  .field:hover { background: #efeff2; }
  .field.is-open:hover { background: #fff; }
  .seg__opt:hover { color: var(--testo); }
}
