/*
 * Canonical mobile header.
 * Mirrors the index.html mobile header across page-specific header variants.
 */

.mobile-nav,
.mobile-nav-overlay {
  display: none !important;
}

@media (max-width: 600px) {
  .head,
  .nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 0.75rem !important;
    width: 100% !important;
    min-height: 60px;
    margin: 0 !important;
    padding: 0.75rem 1.25rem !important;
    background: var(--nav-bg, rgba(250, 250, 250, 0.8));
    border-bottom: 1px solid var(--border, var(--rule, rgba(0, 0, 0, 0.08)));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  [data-theme="dark"] .head,
  [data-theme="dark"] .nav {
    background: var(--nav-bg, rgba(0, 0, 0, 0.8));
  }

  .head > .brand,
  .head > .brand-link,
  .nav > .brand,
  .nav > .nav-brand,
  .mobile-header-brand {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    min-width: 0;
    flex: 1 1 auto !important;
    order: 0 !important;
    color: var(--text, #1d1d1f) !important;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, sans-serif) !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    line-height: 1 !important;
    text-decoration: none !important;
    text-transform: none !important;
  }

  .head > .brand svg,
  .head > .brand-link svg,
  .nav > .brand svg,
  .nav > .nav-brand svg,
  .mobile-header-brand svg {
    width: 28px !important;
    height: 28px !important;
    flex: 0 0 28px !important;
    fill: var(--accent, #c41e3a);
  }

  .head .brand-text,
  .nav .brand-text,
  .mobile-header-brand span {
    color: var(--text, #1d1d1f) !important;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, sans-serif) !important;
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    line-height: 1 !important;
    text-transform: none !important;
  }

  .site-nav,
  .nav-links {
    display: none !important;
  }

  .head > .header-actions,
  .nav > .nav-actions {
    position: static !important;
    top: auto !important;
    right: auto !important;
    z-index: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
    flex: 0 0 auto !important;
    gap: 0.5rem !important;
    order: 1 !important;
    width: auto !important;
    margin: 0 !important;
  }

  .head > .header-actions .share-buttons,
  .nav > .nav-actions .share-buttons {
    display: none !important;
  }

  .theme-toggle,
  .menu-toggle {
    position: static !important;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 36px !important;
    height: 36px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid var(--border, var(--rule, rgba(0, 0, 0, 0.08))) !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: var(--text-secondary, var(--text-dim, currentColor)) !important;
    cursor: pointer;
  }

  .menu-toggle {
    display: flex !important;
  }

  .theme-toggle svg,
  .menu-toggle svg {
    width: 16px !important;
    height: 16px !important;
    flex: 0 0 16px;
  }

  .menu-toggle svg {
    stroke: currentColor;
  }

  .menu-toggle .close-icon {
    display: none;
  }

  .menu-toggle.active .menu-icon {
    display: none;
  }

  .menu-toggle.active .close-icon {
    display: block;
  }

  .theme-toggle .sun {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .theme-toggle .moon {
    fill: currentColor;
    stroke: none;
  }

  [data-theme="dark"] .theme-toggle .sun {
    display: none !important;
  }

  [data-theme="dark"] .theme-toggle .moon {
    display: block !important;
  }

  [data-theme="light"] .theme-toggle .sun {
    display: block !important;
  }

  [data-theme="light"] .theme-toggle .moon {
    display: none !important;
  }

  .mobile-nav,
  .mobile-nav-overlay {
    display: block !important;
  }

  .mobile-nav {
    position: fixed;
    top: 0;
    right: -280px;
    z-index: 200;
    width: 280px;
    max-width: 82vw;
    height: 100vh;
    height: 100dvh;
    padding: 5rem 1.5rem 2rem;
    overflow-y: auto;
    background: var(--bg-elevated, var(--bg, #fff));
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transition: right 0.3s ease;
  }

  .mobile-nav.active {
    right: 0;
  }

  .mobile-nav-overlay {
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  .mobile-nav-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }

  .mobile-nav-links a {
    display: block;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--text, #1d1d1f);
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, sans-serif);
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
  }

  .mobile-nav-links a:hover,
  .mobile-nav-links a:focus {
    color: var(--accent, #c41e3a);
    background: var(--glow, var(--accent-soft, rgba(196, 30, 58, 0.12)));
  }

  .mobile-nav-links .support-link {
    margin-top: 1rem;
    border: 1px solid var(--accent, #c41e3a);
    color: var(--accent, #c41e3a);
    text-align: center;
  }

  .mobile-header-brand {
    position: fixed;
    top: 0.75rem;
    left: 1.25rem;
    z-index: 100;
  }

  .mobile-header-shell {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99;
    display: block;
    min-height: 60px;
    background: var(--nav-bg, rgba(250, 250, 250, 0.8));
    border-bottom: 1px solid var(--border, var(--rule, rgba(0, 0, 0, 0.08)));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
}

@media (min-width: 601px) {
  .mobile-header-brand,
  .mobile-header-shell {
    display: none !important;
  }
}

@media (max-width: 600px) and (prefers-reduced-motion: reduce) {
  .mobile-nav,
  .mobile-nav-overlay {
    transition: none;
  }
}
