/* Shared styles for the no-JS landing (index.html) and results page
   (search/templates/results.html). Ported from Landing.css, SearchInput.css
   and WebResults.css so server-rendered markup matches the React UI. */

:root {
  --h-pad: 1.5rem;
  --content-left: 148px;
  --results-width: 660px;
  --logo-size: 32px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: #0d0f17;
  color: #e2e4ed;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell",
    "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Search input ── */

.search-input-form {
  width: 100%;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0 2.75rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  transition:
    border-color 0.15s,
    background 0.15s;
}

.search-input-wrap:focus-within {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.09);
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 0;
  border: none;
  background: transparent;
  color: #e2e4ed;
  font-size: 1rem;
  /* line-height:1 keeps glyphs optically centered: the font's "normal" leading
     is top-heavy, so uppercase text otherwise sits high in the line box. */
  line-height: 1;
  outline: none;
  box-sizing: border-box;
}

/* Reserve room for the clear button only while the field has text, so empty
   input text/placeholder still starts flush after the search glyph. */
.search-input:not(:placeholder-shown) {
  padding-right: 1.9rem;
}

.search-input::placeholder {
  color: rgba(226, 228, 237, 0.4);
}

.search-input-btn {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  background: none;
  border: none;
  border-radius: 50%;
  color: rgba(226, 228, 237, 0.4);
  cursor: pointer;
  transition:
    color 0.15s,
    background 0.15s;
}

/* Icons as CSS masks (not inline <svg>): keeps currentColor theming and avoids
   inline SVG, which the rolldown-vite dev HTML transform mis-parses. */
.search-glyph {
  width: 16px;
  height: 16px;
  display: block;
  background-color: currentColor;
  -webkit-mask: var(--glyph) center / contain no-repeat;
  mask: var(--glyph) center / contain no-repeat;
}

.search-glyph--search {
  --glyph: url(/icon-search.svg);
}

.search-glyph--tor {
  --glyph: url(/icon-tor.svg);
}

.search-glyph--clear {
  --glyph: url(/icon-clear.svg);
}

.search-input-btn--left {
  left: 0.5rem;
}

.search-input-btn--tor-alone {
  right: 0.5rem;
}

/* Clear button sits just left of the tor toggle. Shown only when the field has
   text — pure-CSS via :placeholder-shown so it works without enhance.js too. */
.search-input-btn--clear {
  right: 2.75rem;
}

.search-input:placeholder-shown ~ .search-input-btn--clear {
  display: none;
}

.search-input-btn:hover {
  color: rgba(226, 228, 237, 0.9);
  background: rgba(255, 255, 255, 0.08);
}

.search-input-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Tor toggle as a real checkbox for the no-JS form: hide the box, drive the
   active styling from :checked. enhance.js mirrors this for the JS path. */
.search-input-tor-checkbox {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  margin: 0;
  pointer-events: none;
}

.search-input-btn--tor:has(.search-input-tor-checkbox:checked) {
  color: #c4b5fd;
  background: rgba(124, 58, 237, 0.18);
}

.search-input-btn--tor:has(.search-input-tor-checkbox:checked):hover {
  color: #ddd6fe;
  background: rgba(124, 58, 237, 0.26);
}

/* ── Landing ── */

.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  height: 100vh;
  /* biome-ignore lint/suspicious/noDuplicateProperties: svh fallback for older browsers */
  height: 100svh;
  min-height: 100vh;
  /* biome-ignore lint/suspicious/noDuplicateProperties: svh fallback for older browsers */
  min-height: 100svh;
  overflow: hidden;
  padding: 0 1rem;
  width: 100%;
}

.landing-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  flex: 1;
  justify-content: center;
  width: 100%;
  max-width: 600px;
  padding-bottom: 8vh;
}

.landing-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.landing-brand:hover {
  opacity: 0.8;
}

.landing-logo {
  width: 52px;
  height: 52px;
  border-radius: 10px;
}

.landing-wordmark {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #e2e4ed;
  user-select: none;
}

.landing-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.landing-footer {
  padding: 1.5rem 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  font-size: 0.8rem;
  width: 100%;
}

.landing-footer a {
  color: rgba(226, 228, 237, 0.45);
  text-decoration: none;
}

.landing-footer a:hover {
  color: #e2e4ed;
}

.landing-solo-badge {
  position: var(--landing-solo-position, fixed);
  bottom: var(--landing-solo-bottom, 4rem);
  left: var(--landing-solo-left, 1.75rem);
  order: var(--landing-solo-order, initial);
  width: var(--landing-solo-width, auto);
  max-width: var(--landing-solo-max-width, calc(100vw - 3.5rem));
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: var(--landing-solo-padding, 0.75rem 1rem);
  margin-bottom: var(--landing-solo-margin-bottom, 0);
  flex-shrink: 0;
  color: inherit;
  text-decoration: none;
}

.landing-solo-logo {
  width: 52px;
  height: 52px;
  border-radius: 10px;
}

.landing-solo-text {
  margin: 0;
  font-size: 0.88rem;
  color: rgba(226, 228, 237, 0.55);
  line-height: 1.45;
  max-width: 200px;
}

@media (max-width: 640px) {
  .landing {
    --landing-solo-position: static;
    --landing-solo-order: 2;
    --landing-solo-width: 100%;
    --landing-solo-max-width: none;
    --landing-solo-padding: 0.625rem 0.75rem;
    --landing-solo-margin-bottom: 0.25rem;

    padding-right: max(1rem, env(safe-area-inset-right));
    padding-left: max(1rem, env(safe-area-inset-left));
  }

  .landing-center {
    gap: 1.5rem;
    padding-bottom: 10vh;
  }

  .landing-footer {
    gap: 0.875rem 1rem;
    padding: 1rem 0 calc(1rem + env(safe-area-inset-bottom));
    order: 3;
  }

  .landing-solo-logo {
    width: 40px;
    height: 40px;
  }

  .landing-solo-text {
    max-width: none;
    font-size: 0.8rem;
  }
}

/* ── Web results ── */

.web-results {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.web-results-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem max(var(--h-pad), calc(100% - var(--content-left) - var(--results-width)))
    0.75rem var(--content-left);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
  background: #0d0f17;
}

.web-results-brand {
  box-sizing: border-box;
  width: var(--logo-size);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  line-height: 0;
}

.web-results-logo {
  width: var(--logo-size);
  height: var(--logo-size);
  border-radius: 6px;
}

.web-results-form {
  flex: 1;
  max-width: none;
}

.web-results-body {
  padding: 1.25rem 1.5rem 3rem var(--content-left);
  max-width: calc(var(--content-left) + var(--results-width));
}

.web-results-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.web-results-item {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  border-radius: 6px;
  scroll-margin: 1rem;
}

.web-results-result-content {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.2rem;
}

.web-results-title-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.web-results-favicon {
  display: grid;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  place-items: center;
  overflow: hidden;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(226, 228, 237, 0.42);
}

.web-results-favicon-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.web-results-favicon-fallback {
  width: 14px;
  height: 14px;
}

@media (hover: hover) and (pointer: fine) {
  .web-results-item--selected::before {
    content: "";
    position: absolute;
    inset: -5px;
    border: 1px solid rgba(138, 180, 248, 0.8);
    border-radius: 9px;
    pointer-events: none;
  }
}

.web-results-title {
  font-size: 1rem;
  line-height: 1.25;
  font-weight: 500;
  color: #8ab4f8;
  text-decoration: none;
}

.web-results-title:hover {
  text-decoration: underline;
}

.web-results-url {
  font-size: 0.78rem;
  line-height: 1.25;
  color: rgba(226, 228, 237, 0.45);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.web-results-snippet {
  margin: 0;
  font-size: 0.88rem;
  color: rgba(226, 228, 237, 0.75);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.web-results-empty {
  color: rgba(226, 228, 237, 0.5);
  font-size: 0.95rem;
  margin-top: 2rem;
}

.web-results-neotree-suggestion {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.7rem 0.9rem;
  margin-bottom: 1.25rem;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.28);
  cursor: pointer;
  text-align: left;
  text-decoration: none;
  color: inherit;
  font-family: inherit;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.web-results-neotree-suggestion:hover {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.45);
}

.web-results-neotree-icon {
  width: 16px;
  height: 16px;
  color: #818cf8;
  flex-shrink: 0;
}

.web-results-neotree-label {
  font-size: 0.72rem;
  color: rgba(226, 228, 237, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.web-results-neotree-name {
  font-size: 0.92rem;
  color: #a5b4fc;
  font-weight: 500;
  flex: 1;
}

.web-results-neotree-arrow {
  width: 14px;
  height: 14px;
  color: rgba(226, 228, 237, 0.35);
  flex-shrink: 0;
}

.web-results-timing {
  font-size: 0.75rem;
  line-height: 1.5;
  color: rgba(226, 228, 237, 0.35);
  margin-bottom: 1rem;
  min-height: 1.5em;
  font-variant-numeric: tabular-nums;
}

.web-results-timing--loading {
  display: flex;
  align-items: center;
}

/* ── Loading: timing-line shimmer + matrix rain results ──
   enhance.js renders this skeleton in place during an in-place search. */

@keyframes web-shimmer {
  0% {
    background-position: -600px 0;
  }
  100% {
    background-position: 600px 0;
  }
}

.web-results-sk {
  border-radius: 4px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.12) 50%,
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 600px 100%;
  animation: web-shimmer 1.4s infinite linear;
}

/* Streamed reload: once the real results arrive, hide the skeleton (no-JS safe;
   enhance.js also drops the node). */
.web-results-body:has(.web-results-real) .web-results-skeleton {
  display: none;
}

/* placeholder rows reuse the real result classes for a pixel-identical
   silhouette; the canvas overlays them and fills each box with rain */
.web-results-rain-wrap {
  position: relative;
}

.web-results-rain {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.web-results-ph {
  color: transparent;
  border-radius: 4px;
}

.web-results-ph-snippet {
  font-size: 0.88rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

@media (prefers-reduced-motion: reduce) {
  .web-results-sk {
    animation: none;
  }
}

@media (max-width: 900px) {
  .web-results-header {
    padding-right: max(var(--h-pad), calc((100% - var(--results-width)) / 2));
    padding-left: max(var(--h-pad), calc((100% - var(--results-width)) / 2));
    justify-content: flex-start;
  }

  .web-results-body {
    width: min(var(--results-width), calc(100% - (var(--h-pad) * 2)));
    max-width: none;
    margin: 0 auto;
    padding: 1.25rem 0 3rem;
  }
}

@media (max-width: 600px) {
  .web-results-header {
    padding: 0.6rem var(--h-pad);
  }

  .web-results-brand {
    width: auto;
  }

  .web-results-body {
    padding-top: 1rem;
  }
}
