/* Site-wide Search button and editorial sheet (Option 1, 26 Nov 2026).
   Mirrors share.css: quiet text button in the top bar opening a centered paper sheet
   with a 3px subject-pastel top border, sharp hairlines, and a bottom sheet on phones.
   Powered by Cloudflare AI Search (/.well-known/search) + instant /api/*.json catalog. */

.nav__item--search {
  display: flex;
  align-items: center;
}

.nav__search {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.25rem;
  padding: 1.25rem 0 1.25rem 0.65rem;
  border: 0;
  border-left: var(--hair) solid var(--line-strong);
  background: none;
  color: var(--ink);
  font: 400 var(--fs-small)/1 var(--sans);
  letter-spacing: 0.01em;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.nav__search-icon {
  flex: none;
  width: 0.9rem;
  height: 0.9rem;
  color: var(--ink-2);
  transition: color 0.15s ease;
}

.nav__search-label {
  text-decoration: underline;
  text-decoration-color: transparent;
  text-decoration-thickness: var(--hair);
  text-underline-offset: 0.3em;
  transition: text-decoration-color 0.15s ease;
}

.nav__search:hover {
  color: var(--accent);
}

.nav__search:hover .nav__search-icon {
  color: var(--accent);
}

.nav__search:hover .nav__search-label {
  text-decoration-color: currentColor;
}

.nav__search:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -4px;
}

@media (max-width: 720px) {
  .nav__search {
    margin-left: 0.15rem;
    padding: 1.25rem 0 1.25rem 0.5rem;
  }
  .nav__search-label {
    display: none;
  }
}

@media (max-width: 380px) {
  .nav__search {
    margin-left: 0;
    padding: 1rem 0 1rem 0.4rem;
  }
}

/* Modal sheet — sits above fixed bar (z-index 100), below skip link (300) */
html.search-on {
  overflow: hidden;
}

.search-sheet {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: grid;
  place-items: start center;
  padding: clamp(2.5rem, 8vh, 5.5rem) 1.25rem 1.25rem;
  background: rgba(24, 24, 27, 0.5);
}

.search-sheet__box {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(40rem, 100%);
  max-height: calc(100dvh - 5rem);
  overflow: hidden;
  background: var(--surface);
  border-top: 3px solid var(--cat);
  box-shadow: 0 18px 50px rgba(24, 24, 27, 0.25);
}

.search-sheet__head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  border-bottom: var(--hair) solid var(--line);
  background: var(--surface);
}

.search-sheet__icon {
  flex: none;
  width: 1rem;
  height: 1rem;
  color: var(--accent);
}

.search-sheet__input {
  flex: 1;
  min-width: 0;
  border: 0;
  padding: 0.15rem 0;
  background: transparent;
  color: var(--ink);
  font: 400 1.05rem/1.35 var(--serif);
  letter-spacing: 0.005em;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.search-sheet__input::placeholder {
  color: var(--ink-3);
}

.search-sheet__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-sheet__clear {
  border: 0;
  background: none;
  padding: 0.25rem 0.45rem;
  color: var(--ink-3);
  font: 400 var(--fs-meta)/1 var(--sans);
  cursor: pointer;
}

.search-sheet__clear:hover {
  color: var(--ink);
}

.search-sheet__close {
  display: grid;
  place-items: center;
  flex: none;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--ink-2);
  font: 400 1.45rem/1 var(--sans);
  cursor: pointer;
}

.search-sheet__close:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.search-sheet__chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  background: var(--surface-2);
  border-bottom: var(--hair) solid var(--line);
}

.search-sheet__chip {
  padding: 0.24rem 0.6rem;
  border: var(--hair) solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font: 400 var(--fs-meta)/1.25 var(--sans);
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.search-sheet__chip:hover {
  border-color: var(--ink-2);
  color: var(--ink);
}

.search-sheet__chip[aria-pressed="true"] {
  background: var(--cat-soft);
  border-color: var(--accent);
  color: var(--ink);
}

.search-sheet__suggest {
  margin-left: auto;
  color: var(--ink-3);
  font: 400 0.75rem/1.3 var(--sans);
}

.search-sheet__suggest button {
  border: 0;
  padding: 0;
  background: none;
  color: var(--ink-2);
  font: inherit;
  text-decoration: underline;
  text-decoration-thickness: var(--hair);
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.search-sheet__suggest button:hover {
  color: var(--accent);
}

.search-sheet__results {
  flex: 1;
  min-height: 8rem;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.search-sheet__empty {
  margin: 0;
  padding: 1.5rem 1rem;
  color: var(--ink-2);
  font: 400 var(--fs-small)/1.5 var(--serif);
}

.search-sheet__item {
  display: block;
  padding: 0.72rem 1rem;
  border-bottom: var(--hair) solid var(--grey-200);
  transition: background-color 0.1s ease;
}

.search-sheet__item:last-child {
  border-bottom: 0;
}

.search-sheet__item:hover,
.search-sheet__item.is-active {
  background: var(--cat-soft);
}

.search-sheet__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.65rem;
}

.search-sheet__title {
  color: var(--ink);
  font: 400 0.98rem/1.32 var(--serif);
  text-decoration: none;
}

.search-sheet__title:hover {
  text-decoration: underline;
  text-decoration-thickness: var(--hair);
  text-underline-offset: 0.2em;
}

.search-sheet__badge {
  flex: none;
  padding: 0.12rem 0.42rem;
  border: var(--hair) solid var(--cat-line);
  background: var(--cat-surface);
  color: var(--accent);
  font: 400 0.72rem/1.2 var(--sans);
  white-space: nowrap;
}

.search-sheet__meta {
  margin: 0.2rem 0 0;
  color: var(--ink-3);
  font: 400 0.78rem/1.35 var(--sans);
}

.search-sheet__snip {
  margin: 0.28rem 0 0;
  color: var(--ink-2);
  font: 400 0.86rem/1.45 var(--serif);
}

.search-sheet__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 0.4rem;
  font: 400 0.78rem/1.2 var(--sans);
}

.search-sheet__actions a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: var(--hair);
  text-underline-offset: 0.22em;
}

.search-sheet__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.55rem 1rem;
  border-top: var(--hair) solid var(--line);
  background: var(--surface-2);
  color: var(--ink-3);
  font: 400 0.75rem/1.3 var(--sans);
}

.search-sheet [hidden] {
  display: none !important;
}

.search-sheet a:focus-visible,
.search-sheet button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Phones: bottom sheet, mirroring share-sheet */
@media (max-width: 760px) {
  .search-sheet {
    align-items: end;
    padding: 0;
  }
  .search-sheet__box {
    max-height: 88dvh;
  }
  .search-sheet__suggest {
    display: none;
  }
  .search-sheet__keys {
    display: none;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .search-sheet__box {
    animation: search-in 0.16s ease-out;
  }
}

@keyframes search-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media print {
  .nav__item--search,
  .search-sheet {
    display: none !important;
  }
}
