/* =========================================================================
   styles/shell.css: the site header (Phase 3). Markup lives in lib/shell.js.
   Self-contained on purpose: it carries its own values (--sh-*) so it looks
   identical on old pages (site.css) and new pages (tokens.css) alike.
   ========================================================================= */

.pcr-shell {
  --sh-bg: rgba(255, 255, 255, 0.88);
  --sh-ink: #333333;
  --sh-muted: #6b6b70;
  --sh-fill: #f4f4f5;
  --sh-fill-hover: #ececee;
  --sh-border: #e4e4e7;
  --sh-border-strong: #d4d4d8;
  --sh-brand: #ff5a1f;
  --sh-brand-hover: #e14a12;
  --sh-brand-ink: #c93f0c;
  --sh-ring: rgba(255, 90, 31, 0.35);
  --sh-sold: #15803d;
  --sh-sold-soft: #ecfdf3;
  --sh-font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sh-mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  position: sticky; top: 0; z-index: 100;
  background: var(--sh-bg);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--sh-border);
  font-family: var(--sh-font);
  color: var(--sh-ink);
  letter-spacing: normal;
  line-height: 1.4;
}
.pcr-shell *, .pcr-shell *::before, .pcr-shell *::after { box-sizing: border-box; }
/* Neutralise the old site.css rules that target bare header / a elements */
header.pcr-shell { display: block; padding: 0; margin: 0; gap: 0; max-height: none; overflow: visible; justify-content: normal; }
.pcr-shell a, .pcr-shell a:hover, .pcr-shell a:focus { text-decoration: none; }
.pcr-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* The old site.css sets body { overflow-x: hidden }, which turns <body> into a
   scroll box and silently breaks position: sticky. clip hides sideways
   overflow the same way without breaking the sticky header. */
body:has(> .pcr-shell), body:has(.pcr-shell) { overflow-x: clip; }

/* One line on desktop: logo | search | sections | X. Search sits front and centre.
   The markup keeps the nav after the row (so phones can stack it), and the
   row uses display:contents so its children line up with the nav in one bar. */
.pcr-shell__inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 20px; height: 64px; }
.pcr-shell__row { display: contents; }
.pcr-shell__brand { order: 1; }
.pcr-shell__search { order: 2; }
.pcr-nav { order: 3; }
.pcr-shell__actions { order: 4; }

.pcr-shell__brand { display: flex; align-items: center; gap: 10px; flex: none; color: var(--sh-ink); }
.pcr-shell__brand img { width: 30px; height: 30px; display: block; }
.pcr-shell__brand span { font-size: 16px; font-weight: 700; letter-spacing: -0.025em; white-space: nowrap; }
.pcr-shell__brand b { color: var(--sh-brand); font-weight: 700; }

/* Search */
.pcr-shell__search { position: relative; flex: 1 1 560px; min-width: 220px; max-width: 600px; margin: 0 auto 0 8px; }
.pcr-search {
  display: flex; align-items: center; height: 42px; padding: 0 4px 0 14px;
  background: #fff; border: 1px solid var(--sh-border); border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: border-color 150ms, box-shadow 150ms;
}
.pcr-search:hover { border-color: var(--sh-border-strong); }
.pcr-search:focus-within { border-color: var(--sh-brand); box-shadow: 0 0 0 4px var(--sh-ring); }
.pcr-search__icon { display: grid; place-items: center; color: var(--sh-muted); flex: none; }
.pcr-search__icon svg, .pcr-search__submit svg { width: 18px; height: 18px; display: block; }
.pcr-search__input {
  flex: 1; min-width: 0; height: 100%; padding: 0 10px; margin: 0;
  font: 400 15px/1 var(--sh-font); color: var(--sh-ink);
  background: transparent; border: 0; outline: none; box-shadow: none;
  -webkit-appearance: none; appearance: none;
}
.pcr-search__input::placeholder { color: var(--sh-muted); opacity: 1; }
.pcr-search__input::-webkit-search-cancel-button { -webkit-appearance: none; }
/* Keyboard hint hidden (Oct 2026): it confused people. The "/" shortcut still works. */
.pcr-search__kbd { display: none !important; }
.pcr-search__submit {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none; padding: 0;
  color: #fff; background: var(--sh-brand); border: 0; border-radius: 999px; cursor: pointer;
  transition: background 150ms;
}
.pcr-search__submit:hover { background: var(--sh-brand-hover); }
.pcr-search__submit:focus-visible { outline: 2px solid var(--sh-brand); outline-offset: 2px; }

/* Suggestions */
.pcr-suggest {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 110;
  max-height: min(70vh, 520px); overflow-y: auto; padding: 6px;
  background: #fff; border: 1px solid var(--sh-border); border-radius: 12px;
  box-shadow: 0 16px 40px -12px rgba(0,0,0,0.18), 0 4px 10px -4px rgba(0,0,0,0.06);
}
.pcr-suggest[hidden] { display: none; }
.pcr-suggest__group {
  padding: 10px 10px 4px; font: 500 11px/1 var(--sh-mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--sh-muted);
}
.pcr-suggest__item {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; color: var(--sh-ink); cursor: pointer;
}
.pcr-suggest__item[aria-selected='true'], .pcr-suggest__item:hover { background: var(--sh-fill); }
.pcr-suggest__avatar {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none; overflow: hidden;
  font: 600 11px/1 var(--sh-font); color: var(--sh-muted); background: var(--sh-fill); border: 1px solid var(--sh-border); border-radius: 50%;
}
.pcr-suggest__avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcr-suggest__text { min-width: 0; }
.pcr-suggest__name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcr-suggest__name mark { background: none; color: inherit; font-weight: 700; }
.pcr-suggest__meta { font-size: 12px; color: var(--sh-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcr-suggest__right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }
.pcr-suggest__rank { font: 600 12px/1 var(--sh-mono); color: var(--sh-muted); }
.pcr-suggest__tag { padding: 3px 6px; font: 600 10px/1 var(--sh-mono); letter-spacing: 0.04em; text-transform: uppercase; border-radius: 4px; color: var(--sh-sold); background: var(--sh-sold-soft); }
.pcr-suggest__all {
  display: flex; align-items: center; justify-content: space-between; margin-top: 4px; padding: 10px; border-top: 1px solid var(--sh-border);
  font-size: 13px; font-weight: 500; color: var(--sh-brand-ink); border-radius: 0 0 8px 8px;
}
.pcr-suggest__all[aria-selected='true'], .pcr-suggest__all:hover { background: var(--sh-fill); }
.pcr-suggest__empty { padding: 14px 10px; font-size: 13px; color: var(--sh-muted); }

/* Actions */
.pcr-shell__actions { display: flex; align-items: center; gap: 4px; margin-left: -8px; flex: none; }
.pcr-iconbtn {
  display: grid; place-items: center; width: 36px; height: 36px; color: var(--sh-ink);
  background: transparent; border: 0; border-radius: 8px; cursor: pointer;
}
.pcr-iconbtn:hover { background: var(--sh-fill); }
.pcr-iconbtn svg { width: 16px; height: 16px; display: block; }

/* Section nav */
.pcr-nav {
  display: flex; align-items: center; gap: 2px; flex: none; margin: 0 -4px 0 0;
  transition: height 200ms, opacity 200ms;
}
.pcr-nav > a, .pcr-more__btn {
  display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 12px;
  font: 500 14px/1 var(--sh-font); color: var(--sh-muted); white-space: nowrap;
  background: transparent; border: 0; border-radius: 8px; cursor: pointer;
  transition: color 150ms, background 150ms;
}
.pcr-nav > a:hover, .pcr-more__btn:hover { color: var(--sh-ink); background: var(--sh-fill); }
.pcr-nav > a[aria-current='page'] { color: var(--sh-ink); background: var(--sh-fill); }
.pcr-more__btn svg { width: 14px; height: 14px; }
.pcr-more { position: relative; }
.pcr-more.is-active .pcr-more__btn { color: var(--sh-ink); }
.pcr-more__menu {
  position: absolute; top: calc(100% + 6px); right: 0; left: auto; z-index: 110; min-width: 200px; padding: 6px;
  background: #fff; border: 1px solid var(--sh-border); border-radius: 12px;
  box-shadow: 0 16px 40px -12px rgba(0,0,0,0.18), 0 4px 10px -4px rgba(0,0,0,0.06);
}
.pcr-more__menu[hidden] { display: none; }
.pcr-more__menu a { display: block; padding: 8px 10px; font-size: 14px; color: var(--sh-ink); border-radius: 8px; }
.pcr-more__menu a:hover, .pcr-more__menu a[aria-current='page'] { background: var(--sh-fill); }

/* Laptop / tablet: tighten so everything still fits on one line */
@media (max-width: 1099px) and (min-width: 768px) {
  .pcr-shell__inner { gap: 14px; }
  .pcr-shell__brand span { display: none; }
  .pcr-nav > a, .pcr-more__btn { padding: 0 10px; }
}

/* Phone: two rows. Logo + search on top, sections as a swipeable row below.
   The section row tucks away on scroll down and returns on scroll up. */
@media (max-width: 767px) {
  .pcr-shell__inner { flex-wrap: wrap; height: auto; gap: 0 10px; padding: 9px 12px 0; }
  .pcr-shell__search { order: 2; flex: 1 1 0; min-width: 0; max-width: none; margin: 0; }
  .pcr-nav { order: 3; flex: 0 0 100%; height: 44px; margin: 0; }
  .pcr-shell.is-compact .pcr-nav { height: 0; opacity: 0; overflow: hidden; pointer-events: none; }
  .pcr-shell.is-compact .pcr-shell__inner { padding-bottom: 9px; }
  .pcr-shell__brand span { display: none; }
  .pcr-search { height: 40px; }
  .pcr-search__input { font-size: 16px; } /* 16px stops iOS zooming in on focus */
  .pcr-shell__actions { display: none; }
  .pcr-nav { overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .pcr-nav::-webkit-scrollbar { display: none; }
  .pcr-more { position: static; }
  .pcr-more__menu { left: 12px; right: 12px; top: calc(100% - 2px); }
  .pcr-suggest { position: fixed; top: 58px; left: 8px; right: 8px; max-height: calc(100vh - 72px); }
}

@media (prefers-reduced-motion: reduce) {
  .pcr-nav, .pcr-search, .pcr-search__submit { transition: none; }
}

@media print { .pcr-shell { display: none; } }
