/* The rental search with the words that turn into chips: a single search field of a rental app on white. The words
   typed stay in .field__text; when a part is understood it comes off the sentence and becomes a .chip in the same
   line, with its colour and its icon. The real input sits on top, invisible, and only takes the keys. */
:root {
  --page: #ffffff;          /* the page */
  --field: #ffffff;         /* the field */
  --edge: #e4e4ea;          /* its edge at rest */
  --ink: #16161d;           /* the typed words */
  --muted: #8b8b98;         /* the small words */
  --focus: #4f5bd5;         /* the edge and the ring of the field in use */
  --beds: #4f5bd5;          /* the bedrooms chip */
  --price: #c27512;         /* the price chip */
  --place: #2f8f4e;         /* the place chip */
  --pets: #b4487a;          /* the pets chip */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

.find {
  position: relative;
  width: min(540px, calc(100vw - 32px));
  opacity: 0;
}

/* ---------- the field ---------- */
.field {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr 32px;
  align-items: start;
  column-gap: 10px;
  padding: 0 12px 0 18px;
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfbfd 100%);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 #ffffff,
    0 1px 2px rgba(20, 20, 40, 0.05),
    0 10px 24px -14px rgba(20, 20, 40, 0.18),
    0 28px 56px -30px rgba(20, 20, 40, 0.16);
  transition: box-shadow 0.35s ease;
  cursor: text;
}

.field.is-on {
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--focus) 46%, var(--edge)),
    inset 0 1px 0 #ffffff,
    0 0 0 4px color-mix(in srgb, var(--focus) 11%, transparent),
    0 10px 26px -14px color-mix(in srgb, var(--focus) 30%, rgba(20, 20, 40, 0.2)),
    0 28px 56px -30px rgba(20, 20, 40, 0.18);
}

/* a soft light under the field while it listens */
.field__glow {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -10px;
  height: 26px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--focus) 34%, transparent);
  filter: blur(18px);
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
  z-index: -1;
}

.field.is-on .field__glow {
  opacity: 0.55;
}

.field__lens {
  width: 22px;
  height: 22px;
  margin-top: 19px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
  transition: stroke 0.3s ease;
}

.field.is-on .field__lens {
  stroke: var(--ink);
}

.field__clip {
  position: relative;
  min-width: 0;
  height: 60px;
}

.field__line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: 8px;
  column-gap: 6px;
  min-height: 60px;
  padding: 14px 0;
  font-size: 16px;
  line-height: 32px;
  font-variation-settings: 'wdth' 100;
}

.field__text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-width: 0;
  letter-spacing: -0.005em;
}

.field__text:empty {
  display: none;
}

/* the words just understood, a beat before they come off */
.hit {
  border-radius: 6px;
  background-image: linear-gradient(var(--c), var(--c));
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 0% 2px;
}

.field__caret {
  width: 1.5px;
  height: 20px;
  margin-left: -5px;
  border-radius: 1px;
  background: var(--focus);
  opacity: 0;
}

.field.is-on .field__caret {
  animation: caret 1.05s steps(1) infinite;
}

.field.is-typing .field__caret {
  animation: none;
  opacity: 1;
}

@keyframes caret {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

.field__hint {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: 100%;
  margin-left: -6px;
  pointer-events: none;
}

.field__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0 0 0 50px;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font: inherit;
  font-size: 16px;
  opacity: 0;
  z-index: 1;
  cursor: text;
}

.field__clear {
  position: relative;
  z-index: 3;
  width: 32px;
  height: 32px;
  margin-top: 14px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #f1f1f5;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: background 0.2s ease;
}

.field__clear svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: #5d5d6a;
  stroke-width: 2;
  stroke-linecap: round;
}

.field__clear:focus-visible,
.chip__x:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

@media (hover: hover) {
  .field__clear:hover {
    background: #e7e7ee;
  }
}

/* ---------- the chips ---------- */
.chip {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  height: 32px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  flex: 0 0 auto;
  color: color-mix(in srgb, var(--c) 82%, #0b0b12);
  font-size: 14px;
  font-weight: 560;
  font-variation-settings: 'wdth' 96;
  letter-spacing: -0.004em;
  cursor: default;
}

.chip__bg {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 60%),
    color-mix(in srgb, var(--c) 11%, #ffffff);
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--c) 24%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 2px color-mix(in srgb, var(--c) 16%, transparent),
    0 6px 14px -8px color-mix(in srgb, var(--c) 45%, transparent);
  transition: box-shadow 0.25s ease;
}

.chip.is-armed .chip__bg {
  box-shadow:
    inset 0 0 0 1.5px color-mix(in srgb, var(--c) 70%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 3px color-mix(in srgb, var(--c) 14%, transparent),
    0 6px 14px -8px color-mix(in srgb, var(--c) 55%, transparent);
}

/* a thin light that crosses the chip when it is born */
.chip__shine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  transform: translateX(-120%);
  pointer-events: none;
}

.chip__icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-left: 10px;
  flex: 0 0 auto;
}

.chip__icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--c);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chip__words {
  position: relative;
  display: grid;
  margin-left: 6px;
}

.chip__raw,
.chip__label {
  grid-area: 1 / 1;
}

.chip__raw {
  color: var(--ink);
  font-size: 16px;
  font-weight: 400;
  font-variation-settings: 'wdth' 100;
  opacity: 0;
}

.chip__x {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin: 0 5px 0 4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.2s ease;
}

.chip__x svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.chip__x.is-hover,
.chip__x:active {
  background: color-mix(in srgb, var(--c) 18%, transparent);
}

.chip__x.is-hover svg {
  opacity: 1;
}

@media (hover: hover) {
  .chip__x:hover {
    background: color-mix(in srgb, var(--c) 18%, transparent);
  }

  .chip__x:hover svg {
    opacity: 1;
  }

  /* the chip under the pointer takes a little more light */
  .chip:hover .chip__bg {
    box-shadow:
      inset 0 0 0 1px color-mix(in srgb, var(--c) 40%, transparent),
      inset 0 1px 0 rgba(255, 255, 255, 0.95),
      0 1px 2px color-mix(in srgb, var(--c) 20%, transparent),
      0 8px 18px -8px color-mix(in srgb, var(--c) 55%, transparent);
  }
}

.chip__x:active svg {
  transform: scale(0.82);
}

.chip__x svg {
  transition: opacity 0.2s ease, transform 0.15s ease;
}

/* ---------- under the field ---------- */
.meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 6px 0;
  font-size: 14px;
  color: var(--muted);
}

.meta p {
  margin: 0;
}

.meta__count {
  white-space: nowrap;
}

.meta__count .roll {
  color: var(--ink);
  font-weight: 620;
  font-variation-settings: 'wdth' 104;
}

.roll {
  display: inline-flex;
  vertical-align: bottom;
  height: 20px;
  line-height: 20px;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

.roll__col {
  display: block;
  height: 20px;
}

.roll__strip {
  display: flex;
  flex-direction: column;
}

.roll__strip span,
.roll__sep {
  display: block;
  height: 20px;
}

.meta__read {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta__read svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: color-mix(in srgb, var(--focus) 16%, transparent);
  stroke: var(--focus);
  stroke-width: 1.4;
  stroke-linejoin: round;
}

.meta__read span {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- the autopilot's pointer ---------- */
.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  fill: #16161d;
  stroke: #ffffff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.22));
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

@media (max-width: 420px) {
  .meta {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .field.is-on .field__caret {
    animation: none;
    opacity: 1;
  }

  .ghost {
    display: none;
  }
}
