/* Site search page (templates/search/). Plain CSS, like glossary.css: the
   project's Tailwind palette has no grays, and class names built in templates
   ("bg-{{ color }}-100") are never compiled. Logical properties throughout,
   so Hebrew, Arabic and Persian lay out mirrored. */

:root {
  --search-accent: #003b65;
  --search-accent-soft: #e6eef5;
  --search-text: #1f2937;
  --search-muted: #6b7280;
  --search-border: #e5e7eb;
  --search-surface: #ffffff;
  --search-mark: #fde68a;
  /* Light values; study-appearance.css remaps them for parchment and dark. */
  --search-on-accent: #fff;           /* text on accent fills */
  --search-tint-ink: var(--search-accent); /* accent text on accent-soft tints */
  --search-raised: #f6f8fa;           /* snippets and Ask references inside cards */
  --search-raised-ink: #374151;
  --search-raised-link: var(--search-accent);
  --search-hover-border: #b9cddc;
  --search-focus-ring: rgba(0, 59, 101, 0.15);
  --search-mark-ink: inherit;
  --search-error: #b91c1c;
  --search-kind-lessons-bg: #fdecea;
  --search-kind-lessons-ink: #a12a1f;
  --search-kind-videos-bg: #f1e8f7;
  --search-kind-videos-ink: #6a1b9a;
  --search-kind-blog-bg: #fdf3e1;
  --search-kind-blog-ink: #8a5300;
}

.search-page {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 16px 96px; /* bottom: clear the mobile tab bar */
  color: var(--search-text);
}
@media (min-width: 1024px) {
  .search-page { padding-top: 40px; padding-bottom: 80px; }
  /* Logged-in pages carry the 250px profile sidebar. */
  .search-page--sidebar { margin-inline-start: max(266px, calc((100% - 880px) / 2)); }
}

.search-page__header h1 {
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.15;
  margin: 0 0 16px;
}

/* --- Form ------------------------------------------------------------------ */

.search-form { display: flex; gap: 8px; margin-bottom: 24px; }
.search-form__field { position: relative; flex: 1 1 auto; min-width: 0; }
.search-form__icon {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  color: var(--search-muted);
  pointer-events: none;
}
.search-form input[type="search"] {
  width: 100%;
  height: 48px;
  padding-block: 0;
  padding-inline: 44px 14px;
  border: 1px solid var(--search-border);
  border-radius: 10px;
  background: var(--search-surface);
  font-size: 16px; /* 16px stops iOS from zooming in on focus */
  color: var(--search-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-form input[type="search"]:focus {
  outline: none;
  border-color: var(--search-accent);
  box-shadow: 0 0 0 3px var(--search-focus-ring);
}
.search-form__submit {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--search-accent);
  color: var(--search-on-accent);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
}
.search-form__submit:hover { opacity: 0.92; }
.search-form__submit svg { width: 18px; height: 18px; }
@media (max-width: 479px) {
  /* Phones: icon-only button, so the field keeps its width. */
  .search-form__submit { padding: 0 14px; }
  .search-form__submit span {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  }
}

/* --- Before a search, and when nothing matches ----------------------------- */

.search-tips,
.search-empty {
  padding: 16px 18px;
  border-radius: 10px;
  background: var(--search-accent-soft);
  font-size: 15px;
  line-height: 1.5;
}
.search-tips h2 { margin: 0 0 8px; font-size: 15px; font-weight: 700; }
.search-tips ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.search-tips code {
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--search-surface);
  font-size: 14px;
  white-space: nowrap;
}
.search-empty p { margin: 0; }
.search-empty__title { font-weight: 600; margin-bottom: 4px !important; }

/* --- Summary and tabs ------------------------------------------------------ */

.search-summary { margin: 0 0 12px; color: var(--search-muted); font-size: 15px; }

/* Wrap rather than scroll: on a phone all four kinds stay in view. */
.search-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.search-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border: 1px solid var(--search-border);
  border-radius: 999px;
  background: var(--search-surface);
  color: var(--search-text);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.search-tab:hover { border-color: var(--search-accent); }
.search-tab__count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--search-accent-soft);
  color: var(--search-tint-ink);
  font-size: 12px;
  text-align: center;
}
.search-tab.is-active { background: var(--search-accent); border-color: var(--search-accent); color: var(--search-on-accent); }
.search-tab.is-active .search-tab__count { background: color-mix(in srgb, var(--search-on-accent) 20%, transparent); color: var(--search-on-accent); }
.search-tab.is-empty:not(.is-active) { color: var(--search-muted); }

/* --- Results --------------------------------------------------------------- */

.search-results { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.search-card {
  padding: 16px 18px;
  border: 1px solid var(--search-border);
  border-radius: 12px;
  background: var(--search-surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-card:hover { border-color: var(--search-hover-border); box-shadow: 0 4px 14px rgba(0, 59, 101, 0.07); }

.search-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--search-muted);
}
.search-card__kind {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--search-accent-soft);
  color: var(--search-tint-ink);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.search-card--lessons .search-card__kind { background: var(--search-kind-lessons-bg); color: var(--search-kind-lessons-ink); }
.search-card--videos .search-card__kind { background: var(--search-kind-videos-bg); color: var(--search-kind-videos-ink); }
.search-card--blog_posts .search-card__kind { background: var(--search-kind-blog-bg); color: var(--search-kind-blog-ink); }
a.search-card__byline { color: inherit; text-decoration: underline; text-decoration-color: var(--search-border); text-underline-offset: 2px; }
a.search-card__byline:hover { color: var(--search-accent); }

.search-card__title { margin: 0; font-size: 18px; line-height: 1.35; font-weight: 700; }
.search-card__title a { color: var(--search-accent); text-decoration: none; }
.search-card__title a:hover { text-decoration: underline; }
/* The whole card is the title's link target. */
.search-card { position: relative; }
.search-card__title a::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }
.search-card__meta a { position: relative; z-index: 1; }

.search-card__description {
  margin: 6px 0 0;
  font-size: 15px;
  line-height: 1.5;
  color: var(--search-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-card__snippet {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--search-raised);
  font-size: 14px;
  line-height: 1.55;
  color: var(--search-raised-ink);
  overflow-wrap: anywhere;
}
.search-card__snippet mark {
  background: var(--search-mark);
  color: var(--search-mark-ink);
  padding: 0 2px;
  border-radius: 3px;
}

/* --- Pagination ------------------------------------------------------------ */

.search-pager {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px;
  margin-top: 28px;
}
.search-pager a,
.search-pager span {
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 15px;
  color: var(--search-accent);
  text-decoration: none;
}
.search-pager a:hover { background: var(--search-accent-soft); }
.search-pager .is-current { background: var(--search-accent); color: var(--search-on-accent); font-weight: 700; }
.search-pager__gap { color: var(--search-muted) !important; min-width: 24px !important; padding: 0 !important; }
.search-pager__step { font-weight: 600; }
@media (max-width: 479px) {
  .search-pager__label { display: none; }
}
/* Mirror the arrows for right-to-left languages. */
[dir="rtl"] .search-pager__step span[aria-hidden] { display: inline-block; transform: scaleX(-1); }

/* --- Ask a question (templates/search/partials/ask_box.html) ------------- */

[x-cloak] { display: none !important; }

.ask {
  background: var(--search-surface);
  border: 1px solid var(--search-border);
  border-radius: 12px;
  padding: 16px;
  margin: 0 0 24px;
}
/* Ezra: a monogram (ע, the first letter of עזרא), the name, what it means. */
.ask__head {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: center;
}
.ask__avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--search-accent);
  color: var(--search-on-accent);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1;
  /* The letter sits a little high in most Hebrew faces. */
  padding-top: 2px;
}
.ask__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--search-accent);
  margin: 0;
}
.ask__name { color: var(--search-muted); font-size: 0.8rem; margin: 0; }
.ask__name [lang="he"] { font-weight: 600; }
.ask__intro { grid-column: 1 / -1; color: var(--search-muted); font-size: 0.85rem; margin: 10px 0 12px; }
.ask__form { display: flex; gap: 8px; align-items: stretch; }
.ask__form textarea {
  flex: 1;
  min-width: 0;
  resize: vertical;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--search-border);
  border-radius: 8px;
}
.ask__form textarea:focus { outline: 2px solid var(--search-accent-soft); border-color: var(--search-accent); }
.ask__submit {
  background: var(--search-accent);
  color: var(--search-on-accent);
  border: 0;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.ask__submit:disabled { opacity: 0.6; cursor: default; }
.ask__error { color: var(--search-error); font-size: 0.9rem; margin: 10px 0 0; }
.ask__result { margin-top: 16px; border-top: 1px solid var(--search-border); padding-top: 16px; }
.ask__answer p { margin: 0 0 10px; line-height: 1.65; }
.ask__answer sup { line-height: 0; }
.ask-cite {
  display: inline-block;
  min-width: 1.3em;
  margin-inline-start: 2px;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--search-accent-soft);
  color: var(--search-tint-ink);
  font-size: 0.72rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.ask__message { color: var(--search-muted); margin: 0 0 10px; }
.ask__refs { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.ask__ref { display: flex; gap: 10px; padding: 10px; border-radius: 8px; background: var(--search-raised); }
.ask__ref:target { outline: 2px solid var(--search-accent); }
.ask__ref:not(.is-cited) { opacity: 0.8; }
.ask__ref-n {
  flex: none;
  width: 1.6em;
  height: 1.6em;
  border-radius: 50%;
  background: var(--search-accent);
  color: var(--search-on-accent);
  font-size: 0.75rem;
  font-weight: 600;
  display: grid;
  place-items: center;
}
.ask__ref:not(.is-cited) .ask__ref-n { background: var(--search-muted); }
.ask__ref-title { font-weight: 600; color: var(--search-raised-link); text-decoration: none; }
.ask__ref-title:hover { text-decoration: underline; }
.ask__ref-meta { display: block; color: var(--search-muted); font-size: 0.78rem; margin-top: 2px; }
.ask__ref-text { font-size: 0.85rem; color: var(--search-raised-ink); margin: 6px 0 0; line-height: 1.5; }
.ask__feedback { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--search-muted); font-size: 0.85rem; }
.ask__feedback button {
  display: grid;
  place-items: center;
  background: none;
  border: 1px solid var(--search-border);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--search-muted);
  cursor: pointer;
}
.ask__feedback button:hover { color: var(--search-accent); border-color: var(--search-accent); }
.ask__feedback svg { width: 16px; height: 16px; }
.ask__further { margin-top: 10px; }
.ask__more {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--search-accent);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.ask__more svg { width: 16px; height: 16px; transition: transform 0.15s; }

@media (max-width: 640px) {
  .ask { padding: 12px; border-radius: 10px; }
  .ask__form { flex-direction: column; }
  .ask__submit { padding: 10px; }
}
