/* ── Tokens ─────────────────────────────────────────────────────────── */
:root {
  --black:  #111110;
  --ink:    #1e1e1c;
  --dim:    #2e2e2b;
  --rule:   #3a3a36;
  --mid:    #5a5a55;
  --muted:  #888880;
  --ghost:  #b0b0a8;
  --paper:  #f4f2ee;
  --white:  #faf9f7;
  --red:    #8b1a1a;
  --serif:  'IM Fell English', 'Times New Roman', Georgia, serif;
  --sans:   -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  background: var(--black);
  color: var(--ghost);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100%;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
mark {
  background: transparent;
  color: var(--white);
  font-style: italic;
}

/* ── HOME ───────────────────────────────────────────────────────────── */
body.home { justify-content: center; align-items: center; }

.home-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  width: 100%;
  max-width: 560px;
  padding: 48px 24px;
  flex: 1;
  justify-content: center;
}

.home-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.logo-globe {
  color: var(--rule);
}

.wordmark {
  font-family: var(--serif);
  font-size: 38px;
  font-weight: normal;
  font-style: italic;
  letter-spacing: 0.02em;
  color: var(--ghost);
  line-height: 1;
}

.dot { color: var(--mid); }

.tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--mid);
  letter-spacing: 0.08em;
}

/* search form */
.search-form { width: 100%; }

.search-box {
  display: flex;
  background: var(--ink);
  border: 1px solid var(--rule);
  border-bottom-width: 2px;
}
.search-box:focus-within { border-color: var(--mid); }

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--white);
  font-family: var(--serif);
  font-style: italic;
  font-size: 16px;
  padding: 14px 18px;
  caret-color: var(--ghost);
}
.search-box input::placeholder { color: var(--rule); }

.search-box button {
  background: transparent;
  border: none;
  border-left: 1px solid var(--rule);
  color: var(--mid);
  cursor: pointer;
  padding: 0 20px;
  transition: background 0.1s, color 0.1s;
  display: flex;
  align-items: center;
}
.search-box button:hover { background: var(--dim); color: var(--ghost); }

/* features */
.features {
  list-style: none;
  width: 100%;
  border-top: 1px solid var(--rule);
  padding-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.features li {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--mid);
  padding-left: 16px;
  position: relative;
}
.features li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--rule);
}

/* ── RESULTS LAYOUT ─────────────────────────────────────────────────── */
.layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Sidebar */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  border-right: 1px solid var(--rule);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--mid);
  transition: color 0.1s;
  text-decoration: none;
}
.sidebar-logo:hover { color: var(--ghost); }

.sidebar-wordmark {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--ghost);
}

/* inline search in sidebar */
.inline-search-box {
  display: flex;
  background: var(--ink);
  border: 1px solid var(--rule);
}
.inline-search-box:focus-within { border-color: var(--mid); }

.inline-search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--white);
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  padding: 8px 10px;
  min-width: 0;
  caret-color: var(--ghost);
}
.inline-search-box input::placeholder { color: var(--rule); }

.inline-search-box button {
  background: transparent;
  border: none;
  border-left: 1px solid var(--rule);
  color: var(--mid);
  cursor: pointer;
  padding: 0 10px;
  display: flex;
  align-items: center;
  transition: background 0.1s;
}
.inline-search-box button:hover { background: var(--dim); color: var(--ghost); }

/* Results column */
.results-col {
  flex: 1;
  padding: 28px 48px 48px;
  max-width: 760px;
  overflow-y: auto;
}

.results-meta {
  font-size: 12px;
  color: var(--mid);
  margin-bottom: 24px;
  font-family: var(--serif);
  font-style: italic;
}
.results-time { color: var(--rule); }

/* Result items */
.results-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.result-item { display: flex; flex-direction: column; gap: 3px; }

.result-domain {
  font-size: 11px;
  color: var(--mid);
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--sans);
}
.result-dot { font-size: 5px; color: var(--rule); }

.result-title {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: normal;
  line-height: 1.25;
}
.result-title a {
  color: var(--ghost);
  text-decoration: none;
  transition: color 0.1s;
}
.result-title a:hover { color: var(--white); }

.result-url {
  font-size: 11px;
  color: var(--rule);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--sans);
}

.result-snippet {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 2px;
  font-family: var(--serif);
}

.no-results {
  font-family: var(--serif);
  font-style: italic;
  color: var(--mid);
  padding: 40px 0;
}

/* ── Pagination ─────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 4px;
  margin-top: 40px;
  align-items: center;
  flex-wrap: wrap;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--rule);
  font-family: var(--serif);
  font-size: 13px;
  color: var(--mid);
  text-decoration: none;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.page-btn:hover { background: var(--dim); color: var(--ghost); border-color: var(--mid); }
.page-btn.active {
  background: var(--dim);
  color: var(--ghost);
  border-color: var(--mid);
  pointer-events: none;
}

/* ── Footer ─────────────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--rule);
  padding: 16px 24px;
  display: flex;
  gap: 12px;
  align-items: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  color: var(--mid);
  flex-shrink: 0;
}
.site-footer a { color: var(--mid); transition: color 0.1s; }
.site-footer a:hover { color: var(--ghost); }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 680px) {
  .sidebar { display: none; }
  .results-col { padding: 20px 18px 40px; }

  /* Show inline search at top on mobile */
  body.has-results::before {
    content: '';
  }
}

@media (max-width: 480px) {
  .wordmark { font-size: 28px; }
  .home-wrap { padding: 32px 16px; gap: 24px; }
}

/* ── Category tabs ───────────────────────────────────────────────────── */
.cat-tabs {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-top: 1px solid var(--rule);
  padding-top: 16px;
}

.cat-tab {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--mid);
  padding: 5px 0;
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 10px;
  transition: color 0.1s, border-color 0.1s;
}
.cat-tab:hover { color: var(--ghost); }
.cat-tab.active { color: var(--ghost); border-left-color: var(--ghost); }

/* ── Results meta bar ────────────────────────────────────────────────── */
.results-meta-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.results-meta {
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  color: var(--mid);
}
.results-time { color: var(--rule); }
.related-wrap { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── Suggestions / related ───────────────────────────────────────────── */
.suggestions { margin-top: 20px; }
.suggestions-label {
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  color: var(--mid);
  margin-bottom: 8px;
}
.suggestion-pill {
  display: inline-block;
  border: 1px solid var(--rule);
  padding: 3px 10px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  color: var(--mid);
  text-decoration: none;
  margin: 2px 3px 2px 0;
  transition: border-color 0.1s, color 0.1s;
}
.suggestion-pill:hover { border-color: var(--mid); color: var(--ghost); }
.suggestion-pill.small { font-size: 11px; padding: 2px 8px; }

/* ── Infobox ─────────────────────────────────────────────────────────── */
.infobox {
  display: flex;
  gap: 18px;
  border: 1px solid var(--rule);
  padding: 18px;
  margin-bottom: 28px;
  background: var(--ink);
}
.infobox-img {
  width: 90px;
  height: 90px;
  object-fit: cover;
  flex-shrink: 0;
  filter: grayscale(30%);
}
.infobox-body { min-width: 0; flex: 1; }
.infobox-title {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: normal;
  color: var(--ghost);
  margin-bottom: 8px;
}
.infobox-content {
  font-family: var(--serif);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 10px;
}
.infobox-attrs { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; margin-bottom: 10px; }
.infobox-attr-row { display: contents; }
.infobox-attrs dt { font-size: 11px; color: var(--mid); white-space: nowrap; }
.infobox-attrs dd { font-size: 11px; color: var(--ghost); }
.infobox-links { display: flex; flex-wrap: wrap; gap: 6px; }
.infobox-link {
  font-family: var(--serif);
  font-style: italic;
  font-size: 11px;
  color: var(--mid);
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}
.infobox-link:hover { color: var(--ghost); border-bottom-color: var(--mid); }

/* ── Result items ────────────────────────────────────────────────────── */
.result-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 3px;
}
.result-favicon {
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
  opacity: 0.7;
}
.result-domain {
  font-size: 11px;
  color: var(--mid);
  font-family: var(--sans);
}
.result-date {
  font-family: var(--serif);
  font-style: italic;
  font-size: 11px;
  color: var(--rule);
}

.result-video-thumb {
  position: relative;
  display: inline-block;
  margin: 6px 0;
}
.result-video-thumb img {
  width: 200px;
  height: 112px;
  object-fit: cover;
  display: block;
  filter: grayscale(20%);
}
.video-duration {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(0,0,0,0.75);
  color: var(--ghost);
  font-size: 10px;
  padding: 1px 5px;
  font-family: var(--sans);
}

.result-engines {
  display: flex;
  gap: 4px;
  margin-top: 5px;
  flex-wrap: wrap;
}
.engine-badge {
  font-size: 9px;
  font-family: var(--sans);
  color: var(--rule);
  border: 1px solid var(--dim);
  padding: 1px 5px;
  text-transform: lowercase;
  letter-spacing: 0.03em;
}

/* ── Image grid ──────────────────────────────────────────────────────── */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
}
.image-item {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--ink);
  aspect-ratio: 4/3;
  text-decoration: none;
}
.image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: grayscale(15%);
  transition: filter 0.15s;
}
.image-item:hover img { filter: grayscale(0%); }
.image-domain {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.6);
  font-size: 10px;
  color: var(--ghost);
  padding: 2px 6px;
  font-family: var(--sans);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.15s;
}
.image-item:hover .image-domain { opacity: 1; }

/* ── Error box ───────────────────────────────────────────────────────── */
.error-box {
  border: 1px solid var(--red);
  padding: 16px 18px;
  font-family: var(--serif);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}
.error-box strong { color: var(--red); }
.error-box code {
  font-family: var(--sans);
  font-size: 11px;
  background: var(--dim);
  padding: 1px 5px;
  color: var(--ghost);
}

/* ── Deeplinks / sitelinks ───────────────────────────────────────────── */
.result-deeplinks {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 6px;
  border-left: 1px solid var(--rule);
  padding-left: 10px;
}
.deeplink {
  font-family: var(--serif);
  font-size: 12px;
  color: var(--mid);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  margin: 2px 12px 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.deeplink:hover { color: var(--ghost); border-bottom-color: var(--mid); }
