/* assets/css/navbar.css — site header: nav bar, search, filter panel,
 * notifications and the mobile drawer.
 *
 * Previously split between a 450-line inline <style> in includes/navbar.php and
 * a NAVBAR section in app.css, which had drifted — .nav-primary was declared in
 * both. Everything header-related now lives here; app.css keeps only the shared
 * button and form primitives the rest of the site also uses.
 */

/* The bar is fixed, so it is out of flow and pages must reserve space for it.
   Every page that renders the navbar sets `padding-top: var(--rp-nav-height)`
   on <body>; using the variable rather than a hardcoded 72px keeps that offset
   correct when the bar shrinks on narrow screens. */
:root { --rp-nav-height: 72px; }

/* ── Bar ─────────────────────────────────────────────────────────────────── */
nav#rp-nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 72px;
  padding: 0 clamp(20px, 3vw, 48px);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid transparent;
  transition: border-color .25s ease, box-shadow .25s ease, background .25s ease;
}
/* The border and shadow only appear once the page has moved, so the header
   reads as part of the hero at rest and lifts off it on scroll. */
nav#rp-nav.scrolled {
  background: rgba(255, 255, 255, .92);
  border-bottom-color: var(--cream-dark, #e2e8f0);
  box-shadow: 0 6px 24px rgba(15, 23, 42, .06);
}

.nav-primary {
  display: flex;
  align-items: center;
  gap: clamp(20px, 2.4vw, 34px);
  min-width: 0;
  flex: 1 1 auto;
}

.nav-logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink, #0f172a);
  text-decoration: none;
  letter-spacing: -.02em;
  flex-shrink: 0;
}
.nav-logo span { color: var(--gold, #2563eb); }
.nav-logo:focus-visible {
  outline: 2px solid var(--gold, #2563eb);
  outline-offset: 4px;
  border-radius: 4px;
}

/* ── Links ───────────────────────────────────────────────────────────────── */
.nav-links {
  display: flex;
  align-items: center;
  gap: clamp(14px, 1.6vw, 24px);
  list-style: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}
.nav-links li { flex-shrink: 0; }
.nav-links a {
  position: relative;
  display: block;
  padding: 6px 2px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--ink-muted, #64748b);
  text-decoration: none;
  letter-spacing: .02em;
  white-space: nowrap;
  transition: color .18s ease;
}
/* Underline grows from the centre rather than recolouring the text alone, so
   the current section is readable at a glance. */
.nav-links a::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--gold, #2563eb);
  transform: translateX(-50%);
  transition: width .22s ease;
}
.nav-links a:hover { color: var(--ink, #0f172a); }
.nav-links a:hover::after { width: 100%; }
.nav-links a[aria-current="page"] {
  color: var(--ink, #0f172a);
  font-weight: 600;
}
.nav-links a[aria-current="page"]::after { width: 100%; }
.nav-links a:focus-visible {
  outline: 2px solid var(--gold, #2563eb);
  outline-offset: 3px;
  border-radius: 4px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}
.nav-cta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ── Search ──────────────────────────────────────────────────────────────── */
.nav-search-bar {
  display: flex;
  align-items: stretch;
  width: clamp(280px, 28vw, 440px);
  min-width: 0;
  background: var(--white, #fff);
  border: 1.5px solid var(--cream-dark, #e2e8f0);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.nav-search-bar:focus-within {
  border-color: var(--gold, #2563eb);
  box-shadow: 0 0 0 3px var(--gold-dim, rgba(37, 99, 235, .12));
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  padding: 0 12px;
}
.search-icon { color: var(--ink-muted, #64748b); flex-shrink: 0; margin-right: 8px; }
.search-input {
  width: 100%;
  min-width: 0;
  padding: 9px 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: inherit;
  font-size: .9rem;
  color: var(--ink, #0f172a);
}
.search-input::placeholder { color: var(--ink-muted, #64748b); opacity: .65; }

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: 0 18px;
  border: 0;
  background: var(--ink, #0f172a);
  color: #fff;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .18s ease;
}
.filter-btn:hover { background: var(--ink-soft, #172033); }
.filter-btn[aria-expanded="true"] { background: var(--gold, #2563eb); }
.filter-btn:focus-visible { outline: 2px solid var(--gold, #2563eb); outline-offset: -2px; }

/* ── Popovers (filter panel + notifications share the motion) ────────────── */
.filter-panel,
.notif-dropdown {
  position: absolute;
  background: var(--white, #fff);
  border: 1px solid var(--cream-dark, #e2e8f0);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .14);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity .18s ease, visibility .18s ease, transform .18s ease;
  z-index: 10000;
}
.filter-panel.active,
.notif-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.filter-panel {
  top: 100%;
  right: clamp(20px, 3vw, 48px);
  margin-top: 10px;
  width: 380px;
}
.filter-panel-content { padding: 22px; }
.filter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--cream-dark, #e2e8f0);
}
.filter-panel-header h3 {
  margin: 0;
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ink, #0f172a);
}
.filter-reset-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--gold-dark, #1d4ed8);
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.filter-section { margin-bottom: 18px; }
.filter-label {
  display: block;
  margin-bottom: 7px;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink-muted, #64748b);
  letter-spacing: .02em;
}
.filter-tabs { display: flex; gap: 8px; }
.filter-tab {
  flex: 1;
  padding: 8px 14px;
  border: 1.5px solid var(--cream-dark, #e2e8f0);
  border-radius: 8px;
  background: transparent;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  color: var(--ink-muted, #64748b);
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, color .18s ease;
}
.filter-tab:hover { border-color: var(--gold, #2563eb); color: var(--gold-dark, #1d4ed8); }
.filter-tab[aria-pressed="true"] {
  background: var(--gold, #2563eb);
  border-color: var(--gold, #2563eb);
  color: #fff;
}
.filter-input,
.filter-select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--cream-dark, #e2e8f0);
  border-radius: 8px;
  background: var(--cream, #f8fafc);
  font-family: inherit;
  font-size: .9rem;
  color: var(--ink, #0f172a);
  outline: 0;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.filter-input:focus,
.filter-select:focus {
  border-color: var(--gold, #2563eb);
  box-shadow: 0 0 0 3px var(--gold-dim, rgba(37, 99, 235, .12));
  background: var(--white, #fff);
}
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.filter-apply-btn { width: 100%; margin-top: 6px; }

/* ── Notifications ───────────────────────────────────────────────────────── */
.notif-bell-wrap { position: relative; }
.notif-bell-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1.5px solid var(--cream-dark, #e2e8f0);
  border-radius: 10px;
  background: none;
  color: var(--ink, #0f172a);
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}
.notif-bell-btn:hover,
.notif-bell-btn[aria-expanded="true"] {
  border-color: var(--gold, #2563eb);
  background: var(--gold-dim, rgba(37, 99, 235, .12));
}
.notif-bell-btn:focus-visible { outline: 2px solid var(--gold, #2563eb); outline-offset: 2px; }
.notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 17px;
  padding: .1rem .3rem;
  border: 2px solid var(--white, #fff);
  border-radius: 10px;
  background: #dc2626;
  color: #fff;
  font-size: .62rem;
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
}

.notif-dropdown { top: calc(100% + 10px); right: 0; width: 340px; overflow: hidden; }
.notif-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1.05rem .7rem;
  border-bottom: 1px solid var(--cream-dark, #e2e8f0);
}
.notif-dropdown-title { font-weight: 700; font-size: .9rem; color: var(--ink, #0f172a); }
.notif-mark-all {
  background: none;
  border: 0;
  padding: 0;
  color: var(--gold-dark, #1d4ed8);
  font-family: inherit;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .72rem 1.05rem;
  border-bottom: 1px solid var(--cream-dark, #e2e8f0);
  color: inherit;
  text-decoration: none;
  transition: background .15s ease;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--cream, #f8fafc); }
.notif-item.unread { background: rgba(37, 99, 235, .05); }
.notif-item.unread:hover { background: rgba(37, 99, 235, .09); }
.notif-dot {
  width: 8px;
  height: 8px;
  margin-top: .38rem;
  border-radius: 50%;
  background: transparent;
  flex-shrink: 0;
}
.notif-item.unread .notif-dot { background: var(--gold, #2563eb); }
.notif-item-body { flex: 1; min-width: 0; }
.notif-item-title {
  margin-bottom: .12rem;
  font-size: .83rem;
  font-weight: 600;
  color: var(--ink, #0f172a);
  line-height: 1.35;
}
.notif-item-text {
  margin-bottom: .18rem;
  font-size: .77rem;
  color: var(--ink-muted, #64748b);
  line-height: 1.4;
}
.notif-item-time { font-size: .7rem; color: var(--ink-muted, #64748b); opacity: .75; }
.notif-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: 2rem 1rem;
  color: var(--ink-muted, #64748b);
  font-size: .85rem;
}
.notif-footer {
  display: block;
  padding: .7rem;
  border-top: 1px solid var(--cream-dark, #e2e8f0);
  background: var(--cream, #f8fafc);
  color: var(--gold-dark, #1d4ed8);
  font-size: .8rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}
.notif-footer:hover { background: var(--gold-dim, rgba(37, 99, 235, .12)); }

/* ── Mobile drawer ───────────────────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1.5px solid var(--cream-dark, #e2e8f0);
  border-radius: 10px;
  background: none;
  color: var(--ink, #0f172a);
  cursor: pointer;
}
.nav-hamburger:focus-visible { outline: 2px solid var(--gold, #2563eb); outline-offset: 2px; }

.mobile-menu {
  position: fixed;
  inset: 0;
  z-index: 1200;
  visibility: hidden;
  pointer-events: none;
}
.mobile-menu.open { visibility: visible; pointer-events: auto; }

.mobile-menu-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  opacity: 0;
  transition: opacity .25s ease;
}
.mobile-menu.open .mobile-menu-backdrop { opacity: 1; }

.mobile-menu-panel {
  position: absolute;
  inset: 0 0 0 auto;
  width: min(360px, 86vw);
  display: flex;
  flex-direction: column;
  background: var(--white, #fff);
  box-shadow: -12px 0 40px rgba(15, 23, 42, .18);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  overflow-y: auto;
}
.mobile-menu.open .mobile-menu-panel { transform: translateX(0); }

.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--cream-dark, #e2e8f0);
}
.mobile-menu-close {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: var(--cream, #f8fafc);
  color: var(--ink, #0f172a);
  cursor: pointer;
}
.mobile-menu-close:focus-visible { outline: 2px solid var(--gold, #2563eb); outline-offset: 2px; }

.mobile-menu-search { padding: 1rem 1.25rem 0; }
.mobile-menu-search .nav-search-bar { width: 100%; }

.mobile-menu-links {
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem;
  margin: 0;
  list-style: none;
}
.mobile-menu-links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 0;
  border-bottom: 1px solid var(--cream-dark, #e2e8f0);
  color: var(--ink, #0f172a);
  font-size: 1rem;
  font-weight: 500;
  text-decoration: none;
}
.mobile-menu-links a[aria-current="page"] { color: var(--gold-dark, #1d4ed8); font-weight: 700; }

.mobile-menu-cta {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  padding: .5rem 1.25rem 1.5rem;
  margin-top: auto;
}
.mobile-menu-cta .btn { width: 100%; justify-content: center; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .nav-search-bar { width: clamp(220px, 22vw, 300px); }
}

@media (max-width: 1024px) {
  /* Search moves into the drawer rather than crowding the bar. */
  .nav-actions > .nav-search-bar { display: none; }
  .filter-panel { display: none; }
}

@media (max-width: 860px) {
  /* Keep in step with nav#rp-nav's height below, or every page gains a gap. */
  :root { --rp-nav-height: 64px; }

  nav#rp-nav { height: 64px; padding: 0 20px; }
  .nav-logo { font-size: 1.3rem; }
  .nav-links { display: none; }
  .nav-cta { display: none; }
  .nav-hamburger { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  nav#rp-nav,
  .nav-links a::after,
  .filter-panel,
  .notif-dropdown,
  .mobile-menu-panel,
  .mobile-menu-backdrop { transition: none; }
}
