/* Site Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--header-bg, #FFFFFF);
  border-bottom: 1px solid var(--color-border, #c7c4d7);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height, 72px);
  gap: var(--space-lg, 1.5rem);
}

.site-logo {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  text-decoration: none !important;
}
.site-logo img {
  display: block;
  height: 40px;
  width: auto;
}

.nav-menu {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: var(--space-xs, 0.25rem);
}

.nav-menu li {
  margin: 0;
  padding: 0;
}

.nav-menu a {
  display: block;
  padding: 0.5rem 1rem;
  font-family: var(--font-heading, 'Plus Jakarta Sans', sans-serif);
  font-weight: 500;
  font-size: var(--text-sm, 0.875rem);
  color: var(--header-text, #1c1b1b);
  text-decoration: none !important;
  border-radius: var(--radius-md, 8px);
  transition: all var(--transition-fast, 150ms);
}

.nav-menu a:hover,
.nav-menu a.active {
  color: var(--header-text-hover, #4648d4);
  background: var(--color-bg, #fcf9f8);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm, 0.5rem);
  min-width: 0;
}

.nav-search {
  display: flex;
  align-items: center;
  position: relative;
  /* The search is the one header element allowed to give up width when the
     row gets tight, so the logo and menu button always stay whole. */
  flex: 0 1 auto;
  min-width: 0;
}

.nav-search input {
  width: 200px;
  min-width: 0;
  padding: 0.5rem 2.25rem 0.5rem 0.75rem;
  border: 1px solid var(--color-border, #c7c4d7);
  border-radius: var(--radius-full, 9999px);
  font-size: var(--text-sm, 0.875rem);
  font-family: var(--font-body, 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
  background: var(--color-bg, #fcf9f8);
  color: var(--color-text, #1c1b1b);
  outline: none;
  transition: all var(--transition-fast, 150ms);
}
.nav-search input:focus {
  border-color: var(--color-accent, #4648d4);
  background: var(--color-white, #FFFFFF);
  box-shadow: 0 0 0 3px rgba(70, 72, 212, 0.12);
  width: 260px;
}
.nav-search input::placeholder {
  color: var(--color-text-muted, #727586);
}

.nav-search button {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--color-text-muted, #727586);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast, 150ms);
}
.nav-search button:hover {
  color: var(--color-accent, #4648d4);
}

/* Nav Toggle (mobile) */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  /* Without flex-shrink:0 the button collapses to ~13px in the header row,
     leaving a tap target well under the 44px guideline. */
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--color-primary, #1c1b1b);
  border-radius: 2px;
  transition: all var(--transition-fast, 150ms);
}

/* Mobile */
@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }

  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    padding: var(--space-md);
    box-shadow: var(--shadow-lg);
  }

  .nav-menu.is-open {
    display: flex;
  }

  .nav-search input {
    width: 160px;
  }
  .nav-search input:focus {
    width: 200px;
  }

  .site-nav {
    height: var(--header-height, 60px);
    gap: var(--space-md, 1rem);
  }

  /* The wordmark is 946x160; at 40px tall it is ~236px wide, which pushes
     the search field and nav toggle off a 375px viewport. Step it down. */
  .site-logo img {
    height: 30px;
  }
}

@media (max-width: 480px) {
  .site-logo img {
    height: 26px;
  }

  /* Below 480px there is no room for a usable text field beside the wordmark
     and the menu button — at 120px the placeholder clipped mid-word and read
     as broken. Collapse to the magnifier and expand over the row on focus. */
  .nav-search {
    width: 34px;
    justify-content: flex-end;
  }
  .nav-search input {
    width: 0;
    padding: 0;
    border-color: transparent;
    background: transparent;
  }
  .nav-search input:focus {
    position: absolute;
    right: 0;
    z-index: 2;
    width: calc(100vw - 6rem);
    max-width: 220px;
    padding: 0.5rem 2.25rem 0.5rem 0.75rem;
    border-color: var(--color-accent, #4648d4);
    background: var(--color-white, #FFFFFF);
  }
  .nav-search button {
    z-index: 3;
  }
}

.search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  display: none;
  margin-top: var(--space-xs);
}

.search-dropdown.active {
  display: block;
}

.search-dropdown-item {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  text-decoration: none;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border-light);
  transition: background var(--transition-fast);
}

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

.search-dropdown-item:hover,
.search-dropdown-item:focus {
  background: var(--color-bg-alt);
}

.search-dropdown-item img {
  width: 56px;
  height: 42px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.search-dropdown-item-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.search-dropdown-item-content h4 {
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.35;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-dropdown-item-content .meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.search-dropdown-empty {
  padding: var(--space-xl);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--color-bg-alt);
  border-radius: var(--radius-md);
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.4) 50%,
    transparent 100%
  );
  animation: skeleton-shimmer 1.5s infinite;
}

@keyframes skeleton-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.skeleton-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.skeleton-card .skeleton-img {
  width: 100%;
  aspect-ratio: 16/10;
}

.skeleton-card .skeleton-body {
  padding: var(--space-md) var(--space-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.skeleton-card .skeleton-line {
  height: 14px;
  border-radius: var(--radius-sm);
}

.skeleton-card .skeleton-line.short {
  width: 60%;
}

.skeleton-card .skeleton-line.medium {
  width: 80%;
}
