/* The document search with results grouped in an accordion: the docs search of Cobble, a small team's knowledge
   base, on white. A warm white card with a fine grain, a 1px edge that catches the light and layered shadows. One
   accent, a quiet indigo, and the yellow of a highlighter for the matched word. */
:root {
  --page: #ffffff;                  /* the page */
  --card: #fcfcfa;                  /* the card, warm white */
  --ink: #17171c;                   /* the words */
  --muted: #7d7d87;                 /* the small words */
  --faint: #a9a9b2;                 /* the faintest words */
  --line: rgba(23, 23, 40, 0.085);  /* the 1px edges */
  --accent: #5146e0;                /* the one accent: indigo */
  --accent-soft: rgba(81, 70, 224, 0.075); /* the selection behind a row */
  --marker: #ffdf6e;                /* the highlighter on the matched word */
  --key: #f4f4f6;                   /* the keys in the footer */
  --head-h: clamp(34px, 7.6vh, 42px); /* how tall a folder row is */
  --row-h: clamp(42px, 9.4vh, 54px);  /* how tall a document row is */
}

* {
  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;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 3vh, 18px) 12px;
  overflow: hidden;
}

/* the wrap is GSAP's (entrance), the card is CSS's */
.wrap {
  width: min(560px, 94vw);
  opacity: 0;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: min(438px, calc(100vh - 28px));
  --pad: clamp(8px, 1.8vh, 10px);
  padding: var(--pad);
  border-radius: 20px;
  background:
    radial-gradient(130% 70% at 50% 0%, rgba(255, 255, 255, 0.95), transparent 60%),
    radial-gradient(80% 60% at 100% 100%, rgba(81, 70, 224, 0.035), transparent 70%),
    var(--card);
  box-shadow:
    inset 0 0 0 1px var(--line),
    inset 0 1px 0 rgba(255, 255, 255, 1),
    0 1px 1px rgba(20, 20, 40, 0.04),
    0 4px 10px -4px rgba(20, 20, 40, 0.07),
    0 18px 36px -16px rgba(20, 20, 50, 0.14),
    0 40px 80px -40px rgba(40, 30, 120, 0.18);
  overflow: hidden;
  isolation: isolate;
}

.card__grain {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  opacity: 0.32;
  mix-blend-mode: multiply;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.55 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* a hair of light along the top edge */
.card__sheen {
  position: absolute;
  top: 0;
  left: 14%;
  right: 14%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 1), transparent);
  pointer-events: none;
}

/* ---------------------------------------------------------------- the field */
.field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  height: clamp(42px, 10vh, 50px);
  padding: 0 8px 0 14px;
  border-radius: 13px;
  background: #ffffff;
  box-shadow:
    inset 0 0 0 1px var(--line),
    0 1px 2px rgba(20, 20, 40, 0.05),
    0 6px 14px -10px rgba(20, 20, 60, 0.18);
  transition: box-shadow 0.25s ease;
}

.field.is-focus {
  box-shadow:
    inset 0 0 0 1px rgba(81, 70, 224, 0.5),
    0 0 0 4px rgba(81, 70, 224, 0.09),
    0 1px 2px rgba(20, 20, 40, 0.05),
    0 6px 14px -10px rgba(20, 20, 60, 0.18);
}

.field__lens {
  flex: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.7;
  stroke-linecap: round;
}

.field__type {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 100%;
}

.field__input {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  caret-color: transparent;
  font: 500 clamp(15px, 3.4vh, 16.5px) / 1 'Mona Sans Variable', system-ui, sans-serif;
  font-variation-settings: 'wdth' 100;
  letter-spacing: -0.01em;
}

.field__input::placeholder {
  color: var(--faint);
  font-weight: 450;
}

.field__caret {
  position: absolute;
  left: 0;
  top: 50%;
  width: 1.6px;
  height: 1.15em;
  margin-top: -0.6em;
  border-radius: 1px;
  background: var(--accent);
  font-size: 16px;
  opacity: 0;
  pointer-events: none;
}

.field__measure {
  position: absolute;
  visibility: hidden;
  white-space: pre;
  font: 500 clamp(15px, 3.4vh, 16.5px) / 1 'Mona Sans Variable', system-ui, sans-serif;
  letter-spacing: -0.01em;
}

.field__clear {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
}

.field__clear.is-on {
  pointer-events: auto;
}

.field__clear svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

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

@media (hover: hover) {
  .field__clear:hover {
    background: rgba(23, 23, 40, 0.05);
    color: var(--ink);
  }
}

/* the light that runs under the field while it looks */
.field__beam {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(81, 70, 224, 0.9) 45%, rgba(160, 150, 255, 1) 50%, rgba(81, 70, 224, 0.9) 55%, transparent);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  background-position: -60% 0;
  opacity: 0;
  pointer-events: none;
}

/* ---------------------------------------------------------------- the summary line */
.sum {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex: none;
  padding: clamp(7px, 1.8vh, 11px) 8px clamp(3px, 0.8vh, 5px);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.005em;
}

.sum__count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1.2;
  color: var(--ink);
  font-weight: 600;
}

.roll {
  position: relative;
  display: inline-block;
  height: 1.2em;
  line-height: 1.2em;
  overflow: hidden;
}

.roll__n {
  display: inline-block;
}

.roll__n + .roll__n {
  position: absolute;
  left: 0;
  top: 0;
}

/* ---------------------------------------------------------------- the list */
.list {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 2px 0;
}

.list::-webkit-scrollbar {
  display: none;
}

/* the selection that glides between rows */
.pick {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 40px;
  border-radius: 11px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 60%),
    var(--accent-soft);
  box-shadow:
    inset 0 0 0 1px rgba(81, 70, 224, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 2px rgba(60, 50, 180, 0.06);
  opacity: 0;
  pointer-events: none;
  will-change: transform;
}

.groups {
  position: relative;
}

.group {
  position: relative;
}

.group + .group {
  margin-top: 1px;
}

.head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: var(--head-h);
  padding: 0 10px 0 8px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.head:focus-visible,
.row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.head__tile {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: linear-gradient(180deg, #ffffff, #f1f0f7);
  box-shadow:
    inset 0 0 0 1px rgba(23, 23, 40, 0.08),
    0 1px 1px rgba(20, 20, 40, 0.06),
    0 3px 6px -3px rgba(40, 30, 120, 0.2);
}

.head__tile svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.head__name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  font-variation-settings: 'wdth' 100;
}

.head__badge {
  flex: none;
  min-width: 20px;
  height: 19px;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(23, 23, 40, 0.05);
  box-shadow: inset 0 0 0 1px rgba(23, 23, 40, 0.06);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 19px;
  text-align: center;
}

.group.is-open .head__badge {
  background: rgba(81, 70, 224, 0.1);
  box-shadow: inset 0 0 0 1px rgba(81, 70, 224, 0.16);
  color: var(--accent);
}

.head__chev {
  flex: none;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--faint);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.group.is-open .head__chev {
  stroke: var(--ink);
}

.body {
  height: 0;
  overflow: hidden;
}

.body__in {
  position: relative;
  padding: 0 0 4px 21px;
}

/* the thread that ties the documents to their folder */
.body__in::before {
  content: '';
  position: absolute;
  left: 19.5px;
  top: 0;
  bottom: 10px;
  width: 1px;
  background: linear-gradient(180deg, rgba(23, 23, 40, 0.12), rgba(23, 23, 40, 0.03));
}

.row {
  position: relative;
  display: grid;
  grid-template-columns: 18px 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-content: center;
  width: 100%;
  height: var(--row-h);
  padding: 0 10px 0 12px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.row__icon {
  grid-row: 1 / 3;
  align-self: center;
  width: 16px;
  height: 18px;
  fill: #ffffff;
  stroke: var(--muted);
  stroke-width: 1.3;
  stroke-linejoin: round;
}

.row.is-picked .row__icon {
  stroke: var(--accent);
}

.row__title {
  min-width: 0;
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 560;
  letter-spacing: -0.005em;
  line-height: 1.3;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.row__snip {
  grid-column: 2;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.row__side {
  grid-column: 3;
  grid-row: 1 / 3;
  position: relative;
  align-self: center;
  min-width: 28px;
  height: 22px;
  text-align: right;
}

.row__when {
  display: inline-block;
  color: var(--faint);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 22px;
}

.row__go {
  position: absolute;
  right: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 26px;
  height: 22px;
  border-radius: 6px;
  background: linear-gradient(180deg, #ffffff, #eeedf6);
  box-shadow:
    inset 0 0 0 1px rgba(81, 70, 224, 0.2),
    inset 0 -1px 0 rgba(81, 70, 224, 0.12),
    0 1px 2px rgba(40, 30, 120, 0.12);
  opacity: 0;
}

.row__go svg {
  width: 13px;
  height: 10px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* the matched word and its highlighter stroke */
.hl {
  position: relative;
  display: inline-block;
  z-index: 0;
  color: inherit;
}

.row__title .hl {
  color: var(--ink);
}

.row__snip .hl {
  color: #3a3a44;
  font-weight: 560;
}

.hl__mark {
  position: absolute;
  left: -2px;
  right: -2px;
  top: 12%;
  bottom: 4%;
  z-index: -1;
  border-radius: 3px 5px 4px 3px;
  background:
    linear-gradient(100deg, rgba(255, 255, 255, 0.0) 30%, rgba(255, 255, 255, 0.45) 46%, rgba(255, 255, 255, 0) 60%),
    var(--marker);
  background-size: 260% 100%, 100% 100%;
  background-position: 120% 0, 0 0;
  background-repeat: no-repeat;
  transform: scaleX(0);
  transform-origin: 0 50%;
  mix-blend-mode: multiply;
}

.row__snip .hl__mark {
  top: 18%;
  opacity: 0.75;
}

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
}

.empty svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: var(--faint);
  stroke-width: 1.3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* ---------------------------------------------------------------- the footer and its keys */
.foot {
  display: flex;
  align-items: center;
  gap: clamp(10px, 3vw, 18px);
  flex: none;
  height: clamp(32px, 7.6vh, 38px);
  margin: 0 calc(var(--pad) * -1) calc(var(--pad) * -1);
  padding: 0 18px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(246, 246, 249, 0.9), rgba(250, 250, 251, 0.9));
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}

.hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.hint__w {
  margin-left: 3px;
}

.key {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 19px;
  padding: 0 4px;
  border-radius: 5px;
  background: linear-gradient(180deg, #ffffff, var(--key));
  box-shadow:
    inset 0 0 0 1px rgba(23, 23, 40, 0.1),
    inset 0 -1.5px 0 rgba(23, 23, 40, 0.08),
    0 1px 1px rgba(20, 20, 40, 0.06);
  color: #55555f;
  font: 600 10.5px / 1 'Mona Sans Variable', system-ui, sans-serif;
  letter-spacing: 0.01em;
}

.key--wide {
  min-width: 28px;
}

.key svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.key--wide svg {
  width: 15px;
}

.key.is-down {
  background: linear-gradient(180deg, #eeeef3, #f6f6f8);
  box-shadow:
    inset 0 0 0 1px rgba(81, 70, 224, 0.28),
    inset 0 1px 2px rgba(23, 23, 40, 0.1);
  color: var(--accent);
}

@media (max-width: 420px) {
  .wrap {
    width: 94vw;
  }
  .row__snip {
    font-size: 11.5px;
  }
  .hint:nth-child(3) {
    display: none;
  }
}

@media (max-height: 360px) {
  .sum {
    display: none;
  }
}
