/**
 * @file header.css
 * Site header: branding bar + sticky behaviour.
 */

/* ── Header Shell ─────────────────────────────────────────────────────────── */
.mp-header {
  position: sticky;
  top: 0;
  z-index: var(--mp-z-sticky);
  background: var(--mp-bg-header);
  border-bottom: 1px solid var(--mp-border);
  box-shadow: var(--mp-shadow-sm);
  transition: box-shadow var(--mp-transition);
}

.mp-header.is-scrolled {
  box-shadow: var(--mp-shadow);
}

/* ── Top Row: Branding LEFT | Search + Utilities RIGHT ───────────────────── */
.mp-header__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--mp-space-3);
  gap: var(--mp-space-4);
  flex-wrap: wrap;
}

/* Left: logo + site name */
.mp-header__brand {
  flex-shrink: 0;
}

/* Right: search + utility buttons */
.mp-header__right {
  display: flex;
  align-items: center;
  gap: var(--mp-space-3);
  flex-wrap: wrap;
}

/* ── Search: collapsed icon → expanded form on click ─────────────────────── */
.mp-header__search-wrap {
  position: relative;
}

.mp-header__search-wrap .block,
.mp-header__search-wrap .block__content { margin: 0; }

/* The form is the interactive shell */
.mp-header__search-wrap form {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-full);
  background: var(--mp-bg);
  overflow: hidden;
  transition: width var(--mp-transition),
              border-color var(--mp-transition-fast),
              box-shadow var(--mp-transition-fast);
  width: 40px;       /* collapsed: icon-only button width */
}

/* Expanded state */
.mp-header__search-wrap form.is-expanded {
  width: 280px;
  border-color: var(--mp-primary);
  box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.12);
}

/* Text input — hidden until expanded */
.mp-header__search-wrap input[type="search"],
.mp-header__search-wrap input[type="text"] {
  flex: 1;
  padding: var(--mp-space-2) var(--mp-space-3);
  border: none;
  background: transparent;
  color: var(--mp-text);
  font-size: var(--mp-text-sm);
  outline: none;
  min-width: 0;
  width: 0;
  opacity: 0;
  transition: opacity var(--mp-transition),
              width var(--mp-transition);
  pointer-events: none;
}

.mp-header__search-wrap form.is-expanded input[type="search"],
.mp-header__search-wrap form.is-expanded input[type="text"] {
  width: auto;
  opacity: 1;
  pointer-events: auto;
}

/* Submit button — always visible as a search icon */
.mp-header__search-wrap input[type="submit"],
.mp-header__search-wrap button[type="submit"] {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  background: transparent;
  color: var(--mp-text-secondary);
  border: none;
  cursor: pointer;
  font-size: 0;          /* hide text */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235A4033' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  transition: background-color var(--mp-transition-fast),
              color var(--mp-transition-fast);
  min-height: unset;
  border-radius: var(--mp-radius-full);
}

.mp-header__search-wrap form.is-expanded input[type="submit"],
.mp-header__search-wrap form.is-expanded button[type="submit"] {
  background-color: var(--mp-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  border-radius: 0;
}

.mp-header__search-wrap input[type="submit"]:hover,
.mp-header__search-wrap button[type="submit"]:hover {
  background-color: var(--mp-bg-alt);
}

.mp-header__search-wrap form.is-expanded input[type="submit"]:hover,
.mp-header__search-wrap form.is-expanded button[type="submit"]:hover {
  background-color: var(--mp-primary-hover);
}

@media (max-width: 575.98px) {
  .mp-header__search-wrap form.is-expanded { width: 220px; }
}

/* ── Legacy class — kept for back-compat ─────────────────────────────────── */
.mp-header__branding {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--mp-space-3);
  gap: var(--mp-space-4);
}

/* Site Logo */
.mp-header__logo {
  display: flex;
  align-items: center;
  gap: var(--mp-space-3);
  text-decoration: none;
  flex-shrink: 0;
}

.mp-header__logo img {
  height: 48px;
  width: auto;
  object-fit: contain;
}

.mp-header__logo-text {
  display: flex;
  flex-direction: column;
}

.mp-header__site-name {
  font-size: var(--mp-text-3xl);
  font-weight: 700;
  color: var(--mp-secondary);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.mp-header__site-slogan {
  font-size: var(--mp-text-sm);
  color: var(--mp-text-muted);
  line-height: 1.3;
  font-weight: 400;
}

/* ── Header Right: Actions ────────────────────────────────────────────────── */
.mp-header__actions {
  display: flex;
  align-items: center;
  gap: var(--mp-space-3);
}

/* Search toggle */
.mp-header__search-toggle {
  background: none;
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-full);
  padding: var(--mp-space-2) var(--mp-space-4);
  color: var(--mp-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--mp-space-2);
  font-size: var(--mp-text-sm);
  transition: all var(--mp-transition-fast);
}

.mp-header__search-toggle:hover {
  background: var(--mp-bg-alt);
  border-color: var(--mp-primary);
  color: var(--mp-primary);
}

/* Dark mode toggle */
.mp-dark-mode-toggle {
  background: none;
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-full);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--mp-text-secondary);
  transition: all var(--mp-transition-fast);
  flex-shrink: 0;
}

.mp-dark-mode-toggle:hover {
  background: var(--mp-bg-alt);
  border-color: var(--mp-primary);
  color: var(--mp-primary);
}

/* Mobile nav toggle */
.mp-nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius);
  padding: var(--mp-space-2);
  cursor: pointer;
  color: var(--mp-text);
  line-height: 1;
}

@media (max-width: 991.98px) {
  .mp-nav-toggle { display: flex; align-items: center; }
  .mp-header__search-toggle span { display: none; }
}

/* ── Header Search Bar ────────────────────────────────────────────────────── */
.mp-header__search {
  display: none;
  padding: var(--mp-space-3) 0;
  border-top: 1px solid var(--mp-border);
}

.mp-header__search.is-open {
  display: block;
}

.mp-header__search form {
  display: flex;
  gap: var(--mp-space-2);
}

.mp-header__search input[type="search"] {
  flex: 1;
  padding: var(--mp-space-2) var(--mp-space-4);
  border: 1px solid var(--mp-border);
  border-radius: var(--mp-radius-full);
  background: var(--mp-bg);
  color: var(--mp-text);
  font-size: var(--mp-text-sm);
}

.mp-header__search input[type="search"]:focus {
  border-color: var(--mp-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.15);
}

/* ── User Auth Links ──────────────────────────────────────────────────────── */
.mp-header__auth {
  display: flex;
  gap: var(--mp-space-2);
  font-size: var(--mp-text-sm);
}

.mp-header__auth a {
  padding: var(--mp-space-1) var(--mp-space-3);
  border-radius: var(--mp-radius-full);
  font-weight: 600;
  text-decoration: none;
  transition: all var(--mp-transition-fast);
}

.mp-header__auth .mp-btn-login {
  color: var(--mp-primary);
  border: 1px solid var(--mp-primary);
}

.mp-header__auth .mp-btn-login:hover {
  background: var(--mp-primary);
  color: var(--mp-white);
}

.mp-header__auth .mp-btn-register {
  background: var(--mp-primary);
  color: var(--mp-white);
}

.mp-header__auth .mp-btn-register:hover {
  background: var(--mp-primary-hover);
}

@media (max-width: 575.98px) {
  .mp-header__logo img { height: 36px; }
  .mp-header__site-name { font-size: var(--mp-text-xl); }
  .mp-header__site-slogan { display: none; }
}
