/* ───────────────────────── tokens ───────────────────────── */

@font-face {
  font-family: 'Geist';
  src: url('/assets/GeistVF.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --zinc-950: #09090b;
  --zinc-900: #18181b;
  --zinc-850: #1f1f23;
  --zinc-800: #27272a;
  --zinc-700: #3f3f46;
  --zinc-600: #52525b;
  --zinc-500: #71717a;
  --zinc-400: #a1a1aa;
  --zinc-300: #d4d4d8;
  --zinc-200: #e4e4e7;
  --zinc-100: #f4f4f5;
  --amber: #fbbf24;
  --header-h: 56px;
  --sans: 'Geist', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--zinc-950);
  color: var(--zinc-200);
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ───────────────────────── header ───────────────────────── */

.header {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--zinc-950) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--zinc-800);
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 550;
  font-size: 15px;
  color: var(--zinc-100);
  text-decoration: none;
  white-space: nowrap;
}

.brand img { display: block; }

.searchbox {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 480px;
  height: 34px;
}

.searchbox-icon {
  position: absolute;
  left: 11px;
  color: var(--zinc-500);
  pointer-events: none;
}

#search {
  width: 100%;
  height: 100%;
  padding: 0 34px;
  background: var(--zinc-900);
  border: 1px solid var(--zinc-800);
  border-radius: 8px;
  color: var(--zinc-100);
  font: inherit;
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
#search::-webkit-search-cancel-button { display: none; }
#search::placeholder { color: var(--zinc-500); }
#search:focus { border-color: var(--zinc-600); }

.searchbox-kbd {
  position: absolute;
  right: 9px;
  padding: 1px 6px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--zinc-500);
  background: var(--zinc-850);
  border: 1px solid var(--zinc-700);
  border-radius: 4px;
}
.searchbox:focus-within .searchbox-kbd { visibility: hidden; }

.stat {
  font-size: 12px;
  color: var(--zinc-500);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.about-link {
  margin-left: auto;
  font-size: 13px;
  color: var(--zinc-400);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
}
.about-link:hover { color: var(--zinc-100); background: var(--zinc-900); }

/* ───────────────────────── layout ───────────────────────── */

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: 100vh;
  height: 100dvh;
  padding-top: var(--header-h);
}

/* ───────────────────────── results ───────────────────────── */

.results {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--zinc-800);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 8px;
  flex: 1;
}

.hit {
  display: block;
  width: 100%;
  padding: 10px 12px;
  margin: 0 0 2px;
  background: none;
  border: 0;
  border-radius: 8px;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}
.hit:hover { background: var(--zinc-900); }
.hit.is-selected { background: var(--zinc-850); box-shadow: inset 2px 0 0 var(--amber); }

.hit-title {
  display: block;
  font-weight: 500;
  color: var(--zinc-100);
  line-height: 1.35;
  margin-bottom: 3px;
}

.hit-snippet {
  display: block;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--zinc-400);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.hit-score {
  float: right;
  margin-left: 8px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 400;
  color: var(--amber);
}

.hit mark {
  background: color-mix(in srgb, var(--amber) 22%, transparent);
  color: #fcd34d;
  border-radius: 2px;
  padding: 0 1px;
}
.hit-title mark { color: #fde68a; }

.results-empty {
  padding: 24px 20px;
  color: var(--zinc-500);
  flex: 1;
}

.results-footer {
  padding: 12px 20px;
  font-size: 12px;
  color: var(--zinc-600);
  border-top: 1px solid var(--zinc-800);
}
.results-footer a { color: var(--zinc-500); text-decoration: none; }
.results-footer a:hover { color: var(--zinc-300); }

/* ───────────────────────── viewer ───────────────────────── */

.viewer {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--zinc-900);
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  flex: none;
  padding: 0 16px;
  background: var(--zinc-950);
  border-bottom: 1px solid var(--zinc-800);
}
.viewer-toolbar[hidden] { display: none; }

.toolbar-back {
  display: none;
  background: none;
  border: 0;
  color: var(--zinc-300);
  font: inherit;
  font-size: 16px;
  padding: 4px 8px;
  margin-left: -8px;
  cursor: pointer;
}

.toolbar-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--zinc-300);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.toolbar-original {
  font-size: 12px;
  color: var(--zinc-500);
  text-decoration: none;
  white-space: nowrap;
}
.toolbar-original:hover { color: var(--zinc-200); }

.viewer-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 32px 24px 48px;
}

/* ───────────────────────── about (empty state) ───────────────────────── */

.about {
  max-width: 560px;
  margin: 8vh auto 0;
  color: var(--zinc-400);
  line-height: 1.6;
}

.about h1 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--zinc-100);
  margin: 0 0 10px;
}

.about-tagline { font-size: 15px; margin: 0 0 40px; }

.about h2 {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--zinc-500);
  margin: 32px 0 8px;
}

.about p { margin: 0; }

.about a { color: var(--zinc-200); text-decoration: none; border-bottom: 1px solid var(--zinc-700); }
.about a:hover { border-bottom-color: var(--zinc-400); }

.about-team {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
}

.about-hints { margin-top: 48px !important; font-size: 12px; color: var(--zinc-600); }
.about-hints kbd {
  font-family: var(--sans);
  font-size: 11px;
  padding: 1px 6px;
  background: var(--zinc-900);
  border: 1px solid var(--zinc-800);
  border-radius: 4px;
  color: var(--zinc-500);
}

/* ───────────────────────── skeleton / error ───────────────────────── */

.skeleton-sheet {
  max-width: 850px;
  margin: 0 auto;
  background: #fff;
  border-radius: 4px;
  padding: 64px 72px;
  min-height: 70vh;
}

.skeleton-line {
  height: 12px;
  border-radius: 4px;
  margin-bottom: 18px;
  background: linear-gradient(90deg, #e8e8ec 25%, #f4f4f6 45%, #e8e8ec 65%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.w-40 { width: 40%; margin-bottom: 32px; }
.w-60 { width: 60%; }
.w-75 { width: 75%; }
.w-85 { width: 85%; }
.w-90 { width: 90%; }

@keyframes shimmer { to { background-position: -200% 0; } }

.doc-error {
  max-width: 560px;
  margin: 16vh auto 0;
  text-align: center;
  color: var(--zinc-400);
}
.doc-error a { color: var(--zinc-200); }

/* ───────────────────────── mobile ───────────────────────── */

@media (max-width: 767px) {
  .layout { grid-template-columns: 1fr; }
  .stat { display: none; }
  .searchbox { flex: 1; }
  .searchbox-kbd { display: none; }
  .about-link { padding: 6px 4px; }

  .results { border-right: 0; }

  /* viewer is a full-screen overlay, opened by selecting a doc or tapping About */
  .viewer { display: none; }
  body.has-doc .viewer,
  body.show-about .viewer {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: var(--zinc-900);
  }
  body.show-about .viewer-toolbar { display: flex !important; }
  .viewer-toolbar { height: 48px; }
  .toolbar-back { display: block; font-size: 18px; }

  .viewer-scroll { padding: 0; }
  .skeleton-sheet { padding: 24px 16px; border-radius: 0; min-height: 100vh; }
  .doc-error { padding: 0 24px; }
  .about { margin: 40px auto 0; padding: 0 24px 48px; }
}

/* ───────────────────────── print ───────────────────────── */

@media print {
  html, body { background: #fff; }
  .header, .results, .viewer-toolbar, .about, .skeleton, .doc-error { display: none !important; }
  .layout { display: block; height: auto; padding: 0; }
  .viewer { display: block; background: #fff; }
  .viewer-scroll { overflow: visible; padding: 0; }
}
