/* <nestly-search-demo> — illustrative macOS-style search panel */

nestly-search-demo {
  --nsd-ivory: #FFFCF8; --nsd-peach: #FFB79A; --nsd-coral: #EE8A74; --nsd-lavender: #C7B8FF; --nsd-violet: #6F57E8; --nsd-sky: #A9D4FF;
  --nsd-surface: #FFFEFC; --nsd-sunk: #FBF6F0; --nsd-border: rgba(70,45,25,.09);
  --nsd-chip: rgba(111,87,232,.09); --nsd-chip-b: rgba(111,87,232,.2); --nsd-sel: rgba(111,87,232,.1); --nsd-sel-b: rgba(111,87,232,.42);
  --nsd-mark: rgba(255,183,154,.45);
  --nsd-shadow: 0 1px 2px rgba(60,40,20,.05), 0 30px 70px -32px rgba(90,60,170,.38);
  --nsd-row: 56px; --nsd-gap: 6px;
  display: block; min-height: 454px; container: nsd / inline-size; color: var(--text, #221E1C); font-family: var(--font, -apple-system, BlinkMacSystemFont, sans-serif);
  -webkit-user-select: none; user-select: none;
}
@media (prefers-color-scheme: dark) {
  nestly-search-demo {
    --nsd-surface: #1E1A17; --nsd-sunk: #171310; --nsd-border: rgba(255,240,225,.09);
    --nsd-chip: rgba(185,170,255,.12); --nsd-chip-b: rgba(185,170,255,.24); --nsd-sel: rgba(164,147,255,.14); --nsd-sel-b: rgba(185,170,255,.5);
    --nsd-mark: rgba(255,160,125,.32);
    --nsd-shadow: 0 0 0 1px rgba(255,240,225,.04), 0 30px 80px -30px rgba(0,0,0,.75);
  }
}

.nsd-panel {
  background: var(--nsd-surface); border: 1px solid var(--nsd-border); border-radius: 18px; box-shadow: var(--nsd-shadow);
  overflow: hidden; text-align: left;
}

/* ---- Search bar ---- */
.nsd-bar { display: flex; align-items: center; gap: 12px; height: 58px; padding: 0 16px 0 18px; border-bottom: 1px solid var(--nsd-border); }
.nsd-ic { width: 19px; height: 19px; flex: none; color: var(--nsd-violet); }
@media (prefers-color-scheme: dark) { .nsd-ic { color: #B9AAFF; } }
.nsd-q { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; font-size: 17px; font-weight: 500; letter-spacing: -.012em; white-space: nowrap; overflow: hidden; }
.nsd-qt { overflow: hidden; text-overflow: clip; }
.nsd-ph { position: absolute; left: 0; color: var(--text-3, #9A918A); transition: opacity .2s; }
.nsd.has-q .nsd-ph { opacity: 0; }
.nsd-caret { width: 2px; height: 20px; margin-left: 1px; flex: none; border-radius: 1px; background: var(--nsd-violet); animation: nsdBlink 1.05s steps(1) infinite; }
.nsd.s-typing .nsd-caret { animation: none; }
.nsd.s-results .nsd-caret { opacity: 0; transition: opacity .3s; }
@keyframes nsdBlink { 50% { opacity: 0; } }
.nsd-kbd {
  flex: none; font: 600 11.5px/1 var(--font, sans-serif); letter-spacing: .02em; color: var(--text-3, #9A918A);
  padding: 5px 8px; border-radius: 7px; border: 1px solid var(--nsd-border); background: var(--nsd-sunk); box-shadow: 0 1px 0 var(--nsd-border);
}

/* ---- Understood as ---- */
.nsd-und { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 12px 18px; border-bottom: 1px solid var(--nsd-border); background: var(--nsd-sunk); }
.nsd-lbl { flex: none; font-size: 12px; font-weight: 600; color: var(--text-3, #9A918A); }
.nsd-chips { display: flex; flex-wrap: wrap; gap: 7px; min-height: 30px; align-items: center; }
.nsd-chip {
  display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 9px 0 11px; border-radius: 9px;
  font-size: 12.5px; background: var(--nsd-chip); border: 1px solid var(--nsd-chip-b);
  opacity: 0; transform: translateY(6px) scale(.97);
  transition: opacity .32s var(--ease-out, ease-out), transform .5s var(--nsd-spring, ease-out);
}
.nsd.s-chips .nsd-chip { opacity: 1; transform: none; transition-delay: calc(var(--i) * 110ms); }
.nsd-ck { color: var(--text-2, #6A625C); }
.nsd-chip b { font-weight: 600; }
.nsd-cx { margin-left: 2px; color: var(--text-3, #9A918A); font-size: 13px; line-height: 1; }

/* ---- Results + preview ---- */
.nsd-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 280px); gap: 14px; padding: 12px; }
.nsd-list { position: relative; display: flex; flex-direction: column; gap: var(--nsd-gap); }
.nsd-row {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; height: var(--nsd-row); padding: 0 12px; border-radius: 12px;
  opacity: 0; transform: translateY(8px);
  transition: opacity .35s var(--ease-out, ease-out), transform .55s var(--nsd-settle, ease-out);
}
.nsd.s-results .nsd-row { opacity: 1; transform: none; transition-delay: calc(var(--i) * 110ms); }
.nsd.s-select .nsd-row:not(:first-of-type) { opacity: .78; transition-delay: 0s; }
.nsd-sel {
  position: absolute; left: 0; right: 0; top: 0; height: var(--nsd-row); border-radius: 12px; z-index: 0;
  background: var(--nsd-sel); box-shadow: inset 0 0 0 1.5px var(--nsd-sel-b);
  opacity: 0; transform: translateY(calc(var(--nsd-row) + var(--nsd-gap))) scale(.985);
  transition: opacity .25s var(--ease-out, ease-out), transform .5s var(--nsd-spring, ease-out);
}
.nsd.s-select .nsd-sel { opacity: 1; transform: none; }
.nsd-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.nsd-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.nsd-name b { font-size: 14px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nsd-best {
  flex: none; font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 99px;
  color: #C0563D; background: rgba(238,138,116,.14);
}
@media (prefers-color-scheme: dark) { .nsd-best { color: #FFB49C; background: rgba(255,160,125,.14); } }
.nsd-sub { font-size: 12px; color: var(--text-3, #9A918A); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nsd-why { color: var(--text-2, #6A625C); }
.nsd-why mark { color: inherit; font-weight: 600; background: var(--nsd-mark); border-radius: 4px; padding: 0 3px; }
.nsd-size { flex: none; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text-2, #6A625C); }

/* File glyphs: a page with a coloured band (coral images, lavender docs, sky video, neutral text) */
.nsd-gly { position: relative; flex: none; width: 28px; height: 34px; border-radius: 6px; background: #fff; box-shadow: 0 0 0 1px rgba(60,40,20,.1), 0 2px 4px -1px rgba(60,40,20,.14); overflow: hidden; }
.nsd-gly::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 13px; background: #CFC6BD; }
.nsd-gly[data-k="video"]::before { background: linear-gradient(90deg, #7DB8F7, #A9D4FF); }
.nsd-gly[data-k="image"]::before { background: linear-gradient(90deg, #EE8A74, #FFB79A); }
.nsd-gly[data-k="doc"]::before { background: linear-gradient(90deg, #9C83F0, #C7B8FF); }
.nsd-gly[data-k="video"]::after { content: ""; position: absolute; left: 11px; top: 7px; border: 5px solid transparent; border-left: 7px solid #7DB8F7; border-right: 0; }
.nsd-gly[data-k="text"]::after { content: ""; position: absolute; left: 6px; right: 6px; top: 7px; height: 8px; background: repeating-linear-gradient(#D8D0C8 0 1.5px, transparent 1.5px 3.5px); }

.nsd-prev {
  display: flex; flex-direction: column; gap: 12px; padding: 12px; border-radius: 14px; background: var(--nsd-sunk); border: 1px solid var(--nsd-border);
  opacity: 0; transform: translateX(-10px) scale(.97); transform-origin: 0 20%;
  transition: opacity .35s var(--ease-out, ease-out), transform .6s var(--nsd-settle, ease-out);
}
.nsd.s-preview .nsd-prev { opacity: 1; transform: none; }
.nsd-art { position: relative; aspect-ratio: 16 / 10; border-radius: 10px; overflow: hidden; background: #E9E2F4; }
.nsd-scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.nsd-play { position: absolute; left: 50%; top: 50%; width: 38px; height: 38px; margin: -19px 0 0 -19px; border-radius: 50%; background: rgba(255,255,255,.88); box-shadow: 0 6px 16px -6px rgba(40,20,90,.5); }
.nsd-play::after { content: ""; position: absolute; left: 15px; top: 12px; border: 7px solid transparent; border-left: 11px solid #4D3FA6; border-right: 0; }
.nsd-dur { position: absolute; right: 7px; bottom: 7px; font-size: 10.5px; font-weight: 700; color: #fff; padding: 2px 6px; border-radius: 6px; background: rgba(30,20,60,.55); }
.nsd-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.nsd-meta b { font-size: 14px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nsd-meta span { font-size: 12px; color: var(--text-3, #9A918A); }
.nsd-meta span:first-of-type { color: var(--text-2, #6A625C); }
.nsd-ql { margin-top: 6px; }
.nsd-ql kbd { font: 600 10.5px/1 var(--font, sans-serif); padding: 3px 6px; border-radius: 5px; border: 1px solid var(--nsd-border); background: var(--nsd-surface); color: var(--text-2, #6A625C); margin-right: 3px; }

/* Mock screenshot with an OCR hit */
.nsd-shot { position: absolute; inset: 0; background: linear-gradient(160deg, #FFE7DA, #EDE6FF); display: flex; flex-direction: column; padding: 9% 11%; }
.nsd-shot-bar { display: flex; gap: 4px; padding: 6px 8px; border-radius: 7px 7px 0 0; background: rgba(255,255,255,.75); }
.nsd-shot-bar i { width: 6px; height: 6px; border-radius: 50%; background: #FF6159; } .nsd-shot-bar i:nth-child(2) { background: #FFBD2E; } .nsd-shot-bar i:nth-child(3) { background: #28C941; }
.nsd-shot-body { flex: 1; display: flex; flex-direction: column; gap: 5px; padding: 8px 10px; border-radius: 0 0 7px 7px; background: #fff; }
.nsd-shot-l { display: block; height: 4px; border-radius: 2px; background: #ECE6DF; }
.w45 { width: 45%; } .w60 { width: 60%; } .w80 { width: 80%; }
.nsd-shot-t { font: 600 10px/1.25 ui-monospace, Menlo, monospace; color: #2B2522; white-space: nowrap; }
.nsd-ocr { align-self: flex-start; padding: 1px 3px; border-radius: 3px; background: rgba(255,183,154,.4); box-shadow: 0 0 0 1.5px #EE8A74; }

/* ---- Reset fade between cycles ---- */
.nsd.s-out .nsd-qt, .nsd.s-out .nsd-chips, .nsd.s-out .nsd-list, .nsd.s-out .nsd-prev { opacity: 0 !important; transition: opacity .4s var(--ease-out, ease-out) !important; }
.nsd.nsd-reset *, .nsd.nsd-static * { transition: none !important; }
.nsd.nsd-static .nsd-caret { display: none; }

/* ---- Responsive ---- */
/* Layout follows the panel's own width (it lives in full-width and half-width slots) */
@container nsd (max-width: 860px) {
  .nsd-body { grid-template-columns: minmax(0, 1fr) minmax(0, 220px); }
}
@media (max-width: 640px) { nestly-search-demo { min-height: 560px; --nsd-row: 54px; } }
@container nsd (max-width: 640px) {
  .nsd-bar { height: 52px; padding: 0 12px 0 14px; gap: 10px; }
  .nsd-q { font-size: 15px; }
  .nsd-kbd { display: none; }
  .nsd-und { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 14px; min-height: 92px; }
  .nsd-chips { min-height: 30px; }
  .nsd-body { grid-template-columns: minmax(0, 1fr); padding: 8px; gap: 8px; }
  .nsd-row { gap: 10px; padding: 0 10px; }
  .nsd-best { display: none; }
  .nsd-prev { flex-direction: row; align-items: center; gap: 12px; padding: 8px; transform: translateY(-6px) scale(.98); }
  .nsd-art { flex: none; width: 112px; }
  .nsd-ql { display: none; }
  .nsd-play { width: 26px; height: 26px; margin: -13px 0 0 -13px; }
  .nsd-play::after { left: 10px; top: 7px; border-width: 6px 0 6px 9px; }
}
@container nsd (max-width: 360px) {
  .nsd-size { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .nsd * { transition: none !important; animation: none !important; }
}
