/* ==========================================================================
   OCP Java 17 Prep — Revamped Header & Navigation
   ========================================================================== */

.site-header {
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px max(20px, calc((100% - var(--container-max)) / 2));
  background: rgba(9, 13, 22, 0.82);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

:root[data-theme="light"] .site-header {
  background: rgba(255, 255, 255, 0.88);
}

/* Brand */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover {
  text-decoration: none;
}

.brand span {
  display: inline-block;
  background: linear-gradient(135deg, #4f6df5, #6366f1);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.02em;
  box-shadow: 0 1px 4px rgba(79, 109, 245, 0.3);
}

/* Navigation */
nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

nav > a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

nav > a:hover {
  color: var(--text);
  background: var(--surface-hover);
  text-decoration: none;
}

nav > a.active {
  color: var(--text);
  background: var(--surface-elevated);
  border-color: var(--border-strong);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* Chapter dropdown */
.chapter-nav {
  display: inline-flex;
  align-items: center;
  position: relative;
}

.chapter-nav select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 10px center;
  padding: 6px 28px 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  max-width: 140px;
}

.chapter-nav select:hover {
  color: var(--text);
  background-color: var(--surface-hover);
  border-color: var(--border-strong);
}

.chapter-nav select:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

/* Search form */
.search-form {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: auto;
}

.search-form input {
  width: 165px;
  padding: 6px 12px 6px 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  transition: width 0.2s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-form input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.search-form input:focus {
  width: 215px;
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.search-form button {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 2px;
  cursor: pointer;
}

.search-form input:focus ~ button,
.search-form button:hover {
  color: var(--primary);
}

/* Header action buttons */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  transition: all 0.15s ease;
}

.icon-button:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.icon-button:active {
  transform: translateY(0);
}

/* Header responsive */
@media (max-width: 960px) {
  .site-header {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 16px;
  }
  nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  nav::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 560px) {
  .search-form {
    order: 2;
    margin-left: auto;
  }
  .search-form input {
    width: 130px;
  }
  .search-form input:focus {
    width: 160px;
  }
  .chapter-nav select {
    max-width: 110px;
  }
}
