/* App Bar Styles — References design-system.css variables

   App bar (top navigation) CSS only: menu button, logo, search, breadcrumbs.
   All main pages link this file.

   Nav drawer styles are in _shared/nav-drawer.css (separate file, correct implementation).

   Live: 2026-09-18
*/

/* ========== APP BAR (Top Navigation) ========== */

.app-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-navbar);
  height: var(--navbar-height);
  background: var(--color-paper);
  border-bottom: var(--border-width-hairline) solid var(--color-rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--navbar-padding-y) var(--navbar-padding-x);
  gap: var(--navbar-gap);
  transition: transform var(--scroll-collapse-duration) var(--easing-standard);
}

.app-bar.scrolled {
  height: var(--navbar-height-scrolled);
}

.app-bar.collapsed {
  transform: translateY(-100%);
}

/* ─ Navbar Sections ─ */

.app-bar-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.app-bar-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.app-bar-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

/* ========== MENU BUTTON ========== */

.app-bar-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--spacing-md);
  color: var(--color-ink-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-24);
  transition: color 120ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

/* Animation 4: Menu button morph on hover (elastic scale) — FIXED with !important */
.app-bar-menu-btn {
  transition: color 120ms cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.app-bar-menu-btn:hover {
  color: var(--color-text-on-dark) !important;
}

/* "OPEN MENU" tooltip removed — cleaner header design */

.app-bar-menu-btn .material-symbols-outlined {
  transition: transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  display: block;
}

/* Hover morph: elastic scale inward/outward */
.app-bar-menu-btn:hover .material-symbols-outlined {
  transform: scaleY(0.95) scaleX(1.05) !important;
}

.app-bar-menu-btn.open .material-symbols-outlined {
  animation: hamburgerMorph 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: rotate(90deg) scaleX(-1) !important;
}

@keyframes hamburgerMorph {
  0% {
    transform: rotate(0deg) scaleX(1);
  }
  50% {
    transform: rotate(45deg) scaleX(1.1) scaleY(0.9);
  }
  100% {
    transform: rotate(90deg) scaleX(-1);
  }
}

@keyframes tooltipSlideUp {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ========== NAVBAR LOGO ========== */

.app-bar-logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-14);
  letter-spacing: var(--letter-spacing-wide);
  text-transform: uppercase;
  color: var(--color-ink-secondary);
  text-decoration: none;
  transition: color 120ms cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 150ms cubic-bezier(0.4, 0.6, 0.6, 1);
  position: relative;
  padding: 4px 8px;
  border-radius: 4px;
}

/* Animation 2: Logo glow on hover */
.app-bar-logo:hover {
  color: var(--color-accent-highlight);
  box-shadow: 0 0 16px rgba(212, 175, 55, 0.3);
}

.app-bar-logo span {
  font-size: var(--font-size-12);
  color: var(--color-text-on-dark-secondary);
}

.active-dot {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--color-accent);
  border-radius: 50%;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity var(--duration-medium) var(--easing-ease-out);
}

.active-dot.visible {
  opacity: 1;
}

/* ========== SECTION LABEL / BREADCRUMBS ========== */

.app-bar-section-label {
  font-size: var(--font-size-12);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--letter-spacing-wider);
  text-transform: uppercase;
  color: var(--color-accent-highlight);
  background: var(--color-glass-light);
  padding: var(--spacing-xs) var(--spacing-md);
  border: var(--border-width-hairline) solid var(--color-rule);
  border-radius: var(--border-radius-small);
  position: relative;
  overflow: hidden;
}

/* Pigment hairline: the catalogue's own colours, in proportion, along the
   label's lower edge (--pigment-strip, generated from config/catalog.json by
   tools/generators/gen-pigment.py). Replaces a hover underline that sat at
   bottom:-2px inside overflow:hidden, so it was clipped and never showed, and
   used elastic easing, which the motion rules no longer allow. Static. */
.app-bar-section-label::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--pigment-strip, transparent);
}

/* ========== SEARCH BUTTON ========== */

/* Animation 3: Search button color + icon pulse & rotate on hover */
.app-bar-search-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--spacing-md);
  color: var(--color-ink-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-20);
  position: relative;
  transition: color 120ms cubic-bezier(0.4, 0, 0.2, 1) !important,
              box-shadow 150ms ease-out !important;
}

.app-bar-search-btn:hover {
  color: var(--color-accent) !important;
}

.app-bar-search-btn .material-symbols-outlined {
  transition: transform 150ms cubic-bezier(0.34, 1.56, 0.64, 1) !important;
  display: block;
}

.app-bar-search-btn:hover .material-symbols-outlined {
  transform: scale(1.1) rotate(10deg) !important;
}

.app-bar-search-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-paper),
              0 0 0 4px var(--color-accent);
}

/* ========== FOCUS & ACCESSIBILITY ========== */

.app-bar a:focus-visible,
.app-bar button:focus-visible,
.nav-drawer a:focus-visible,
.nav-drawer button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--color-paper),
              0 0 0 4px var(--color-accent);
  border-radius: var(--border-radius-small);
}

/* ========== REDUCED MOTION ========== */

@media (prefers-reduced-motion: reduce) {
  .app-bar,
  .nav-drawer,
  .nav-drawer-item,
  .nav-drawer-item-count,
  .swipe-hint,
  .nav-drawer-character-image img {
    animation-duration: var(--duration-instant) !important;
    transition-duration: var(--duration-instant) !important;
  }
}

/* ========== MOBILE LAYOUT ========== */

@media (max-width: 768px) {
  .nav-drawer {
    width: 220px;
  }

  .app-bar-section-label {
    font-size: var(--font-size-12);
    padding: var(--spacing-xs) var(--spacing-sm);
  }
}
/* Navbar UX/UI Enhancements — Tier 1 & 2 */

/* ─ Skip Link (Accessibility) ─ */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: var(--on-primary);
  padding: 8px 16px;
  text-decoration: none;
  z-index: var(--z-navbar);
  transition: top 0.2s ease, opacity 0.2s ease;
  opacity: 0;
  pointer-events: none;
}

.skip-link:focus-visible {
  top: 0;
  opacity: 1;
  pointer-events: auto;
}

/* ─ Breadcrumb Navigation ─ */
.breadcrumb-nav {
  padding: 0.75rem 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--outline-variant);
  margin-bottom: 1rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.1);
}

.breadcrumb-nav a {
  color: var(--primary);
  text-decoration: none;
  transition: color 150ms ease;
}

.breadcrumb-nav a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.breadcrumb-nav span {
  color: var(--outline-variant);
  margin: 0 0.5rem;
}

.breadcrumb-nav .breadcrumb-current {
  color: var(--outline-variant);
}

/* ─ Enhanced Focus Rings ─
   NOTE: Primary focus rules are in navbar-shared.css. These are fallbacks only. */
.nav-item:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary);
  border-radius: 0;
}

/* ─ Tooltips ─ */
[data-tooltip] {
  position: relative;
}

[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-container-high);
  color: var(--on-surface);
  padding: 6px 12px;
  border-radius: 0;
  font-size: 11px;
  white-space: nowrap;
  z-index: var(--z-viewer);
  border: 1px solid var(--outline-variant);
  margin-bottom: 8px;
  animation: tooltip-fade-in 150ms ease;
}

[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--surface-container-high);
  z-index: var(--z-viewer);
  margin-bottom: -4px;
}

@keyframes tooltip-fade-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ─ Scroll-Linked Navbar (Hide/Show) ─ */
.app-bar {
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.app-bar.navbar-hidden {
  transform: translateY(-100%);
}

/* ─ Keyboard Shortcuts Modal ─ */
.shortcuts-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: var(--z-system);
  justify-content: center;
  align-items: center;
  animation: fade-in 150ms ease;
}

.shortcuts-overlay.active {
  display: flex;
}

.shortcuts-modal {
  background: var(--surface-container-high);
  border: 1px solid var(--outline-variant);
  padding: 32px;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  border-radius: 0;
}

.shortcuts-modal h2 {
  color: var(--primary);
  font-size: 1.5em;
  margin-bottom: 1.5em;
  font-family: Newsreader, serif;
}

.shortcut-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75em 0;
  border-bottom: 1px solid rgba(212, 175, 55, 0.1);
  font-size: 14px;
}

.shortcut-key {
  background: var(--surface);
  padding: 4px 8px;
  border: 1px solid var(--outline-variant);
  border-radius: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
  color: var(--primary);
  min-width: 40px;
  text-align: center;
}

.shortcut-description {
  color: var(--on-surface);
  flex: 1;
  margin-left: 1em;
}

.shortcuts-close-hint {
  text-align: center;
  color: var(--outline-variant);
  font-size: 12px;
  margin-top: 1.5em;
  padding-top: 1.5em;
  border-top: 1px solid rgba(212, 175, 55, 0.1);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ─ "You Are Here" Indicator ─ */
.section-active-indicator {
  position: fixed;
  left: 0;
  height: 3px;
  background: var(--primary);
  z-index: var(--z-dropdown);
  transition: top 200ms ease;
}

/* ─ Accessibility: Reduce Motion ─ */
@media (prefers-reduced-motion: reduce) {
  .app-bar,
  [data-tooltip]:hover::after,
  .shortcuts-overlay,
  .section-active-indicator {
    transition: none;
    animation: none;
  }

  [data-tooltip]:hover::after {
    animation: none;
  }
}

/* ─ Mobile Adjustments ─ */
@media (max-width: 768px) {
  .breadcrumb-nav {
    font-size: 11px;
  }

  [data-tooltip]:hover::after {
    white-space: normal;
    max-width: 250px;
  }

  .shortcuts-modal {
    width: 90vw;
    max-height: 90vh;
    padding: 24px;
  }
}

/* ══════════════════════════════════════════════════════════════════════════
   TIER 3: DISCOVERY & CONTEXT FEATURES
   ══════════════════════════════════════════════════════════════════════════ */

/* ─ Archive Structure Tooltip ─ */
.archive-structure-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-container-high);
  border: 1px solid var(--outline-variant);
  padding: 12px 16px;
  border-radius: 0;
  font-size: 12px;
  z-index: var(--z-viewer);
  margin-bottom: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.archive-structure-tooltip.visible {
  opacity: 1;
  pointer-events: auto;
}

.archive-structure-item {
  color: var(--on-surface);
  padding: 4px 0;
  display: block;
}

.archive-structure-item.highlight {
  color: var(--primary);
  font-weight: 500;
}

/* ─ Recent Searches ─ */
.recent-searches {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface-container-high);
  border: 1px solid var(--outline-variant);
  border-top: none;
  max-height: 300px;
  overflow-y: auto;
  z-index: var(--z-effect-high);
  display: none;
}

.recent-searches.visible {
  display: block;
}

.recent-search-item {
  padding: 10px 16px;
  color: var(--on-surface);
  text-decoration: none;
  border-bottom: 1px solid rgba(212, 175, 55, 0.1);
  transition: background-color 150ms ease;
  cursor: pointer;
  font-size: 13px;
}

.recent-search-item:hover {
  background-color: var(--surface-container);
  color: var(--primary);
}

.recent-search-item:last-child {
  border-bottom: none;
}

.recent-searches-header {
  padding: 8px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--outline-variant);
  font-weight: 500;
}

.recent-searches-clear {
  padding: 8px 16px;
  font-size: 11px;
  color: var(--outline-variant);
  cursor: pointer;
  transition: color 150ms ease;
  text-align: center;
  border-top: 1px solid rgba(212, 175, 55, 0.1);
}

.recent-searches-clear:hover {
  color: var(--primary);
}

/* ─ Hover State Cascade (Navbar Items) ─ */
.nav-item {
  position: relative;
  overflow: hidden;
}

.nav-item::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--primary);
  transition: width 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover::after {
  width: 100%;
}

/* ─ Mobile Drawer: Swipe-to-Close Support ─ */
.nav-drawer {
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: pan-y;
}

.nav-drawer.swipe-closing {
  transform: translateX(-100%);
  transition: transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─ Reduced Motion: Disable All Tier 3 Animations ─ */
@media (prefers-reduced-motion: reduce) {
  .archive-structure-tooltip,
  .recent-search-item,
  .nav-item::after,
  .nav-drawer {
    transition: none;
  }

  .nav-item::after {
    display: none;
  }

  .archive-structure-tooltip.visible {
    opacity: 1;
  }
}

/* Tap targets: at least 44 x 44px (WCAG 2.5.5). The menu and search buttons
   measured 40px tall on every page and the logo link 26px on record pages. */
.app-bar-menu-btn,
.app-bar-search-btn { min-width: 44px; min-height: 44px; }
.app-bar-logo { display: inline-flex; align-items: center; min-height: 44px; }
