/**
 * Shared header chrome — Modern Minimal Education UI
 * Inspired by Apple / Linear / Notion density (not clones).
 */

.kutby-header {
  --kutby-header-nav-gap: 0.25rem;
  --kutby-header-link: #475569;
  --kutby-header-link-hover: var(--kutby-color-text);
  --kutby-header-surface-hover: color-mix(in srgb, var(--kutby-color-surface) 80%, var(--kutby-color-border));

  position: relative;
  z-index: var(--kutby-z-sticky, 200);
  background: color-mix(in srgb, var(--kutby-color-bg) 86%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--kutby-color-border) 85%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  transition: border-color var(--kutby-transition), background-color var(--kutby-transition);
}

.kutby-header__inner,
.kutby-header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--kutby-space-5);
  min-height: var(--kutby-header-height, 64px);
}

.kutby-header-sticky .kutby-header,
.kutby-header-sticky .kutby-header-stack {
  position: sticky;
  top: 0;
  z-index: var(--kutby-z-sticky, 200);
}

.kutby-header-sticky .kutby-header-stack .kutby-header {
  position: relative;
  z-index: auto;
}

/* Sticky: hairline only — no heavy SaaS/WordPress drop shadow */
.kutby-header-sticky .kutby-header-stack,
.kutby-header-sticky .kutby-header {
  box-shadow: none;
  border-bottom-color: var(--kutby-color-border);
  background: color-mix(in srgb, var(--kutby-color-bg) 92%, transparent);
}

.kutby-header__utilities {
  display: flex;
  align-items: center;
  gap: var(--kutby-space-2);
  flex-shrink: 0;
}

.kutby-branding {
  display: flex;
  align-items: center;
  gap: var(--kutby-space-2);
  line-height: var(--kutby-line-height-tight);
  flex-shrink: 0;
  max-height: calc(var(--kutby-header-height, 64px) - 1rem);
}

.kutby-branding img,
.kutby-branding .custom-logo {
  display: block;
  width: auto;
  max-width: 9.5rem;
  max-height: calc(var(--kutby-header-height, 64px) - 1.25rem);
  height: auto;
  object-fit: contain;
}

.kutby-branding a,
.kutby-logo-text {
  color: var(--kutby-color-text);
  text-decoration: none;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  transition: color var(--kutby-transition), opacity var(--kutby-transition);
}

.kutby-branding a:hover,
.kutby-logo-text:hover {
  color: var(--kutby-color-text);
  opacity: 0.72;
}

.kutby-nav {
  display: flex;
  align-items: center;
  gap: var(--kutby-space-2);
  min-width: 0;
}

.kutby-nav ul,
.kutby-nav .kutby-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--kutby-header-nav-gap);
}

.kutby-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  color: var(--kutby-header-link);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  transition:
    color var(--kutby-transition),
    background-color var(--kutby-transition);
}

.kutby-nav a:hover,
.kutby-nav a:focus-visible {
  color: var(--kutby-header-link-hover);
  background: var(--kutby-header-surface-hover);
}

.kutby-nav .current-menu-item > a,
.kutby-nav .current_page_item > a {
  color: var(--kutby-color-text);
  background: var(--kutby-color-surface);
}

.kutby-nav a:focus-visible,
.kutby-nav-toggle:focus-visible,
.kutby-header-search__link:focus-visible,
.kutby-header-search__submit:focus-visible,
.kutby-header-cta:focus-visible {
  outline: none;
  box-shadow: var(--kutby-focus-ring);
}

.kutby-nav--center {
  justify-content: center;
  flex: 1;
}

.kutby-nav--full {
  width: 100%;
  justify-content: center;
}

.kutby-nav--full ul {
  justify-content: center;
  width: 100%;
}

.kutby-nav-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  color: var(--kutby-color-text);
  cursor: pointer;
  border-radius: var(--kutby-radius-md);
  transition: background-color var(--kutby-transition), border-color var(--kutby-transition);
}

.kutby-nav-toggle:hover {
  background: var(--kutby-header-surface-hover);
}

.kutby-header-search__form {
  display: flex;
  align-items: center;
  gap: var(--kutby-space-2);
}

.kutby-header-search__input {
  min-width: 11rem;
  height: 2.25rem;
  padding: 0 var(--kutby-space-3);
  border: 1px solid var(--kutby-color-border);
  border-radius: 999px;
  background: var(--kutby-color-bg);
  color: var(--kutby-color-text);
  font: inherit;
  font-size: 0.875rem;
  transition: border-color var(--kutby-transition), box-shadow var(--kutby-transition);
}

.kutby-header-search__input.kutby-sr-only {
  min-width: 0;
  max-width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  background: transparent;
}

.kutby-header-search__input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--kutby-color-primary) 45%, var(--kutby-color-border));
  box-shadow: var(--kutby-focus-ring);
}

.kutby-header-search__link,
.kutby-header-search__submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  color: var(--kutby-header-link);
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  border-radius: var(--kutby-radius-md);
  transition:
    color var(--kutby-transition),
    background-color var(--kutby-transition),
    border-color var(--kutby-transition);
}

.kutby-header-search__link:hover,
.kutby-header-search__submit:hover {
  color: var(--kutby-color-text);
  background: var(--kutby-header-surface-hover);
}

.kutby-header-cta.kutby-btn,
.kutby-header-cta {
  min-height: 2.25rem;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 0;
  background: var(--kutby-color-primary);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  box-shadow: none;
  transition:
    background-color var(--kutby-transition),
    transform var(--kutby-transition),
    opacity var(--kutby-transition);
}

.kutby-header-cta.kutby-btn:hover,
.kutby-header-cta:hover {
  background: var(--kutby-color-hover);
  color: #fff;
  opacity: 1;
}

.kutby-announcement {
  background: var(--kutby-color-text);
  color: var(--kutby-color-on-inverse);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.kutby-announcement__inner {
  padding-block: 0.55rem;
  text-align: center;
}

.kutby-announcement__link,
.kutby-announcement__text {
  margin: 0;
  color: inherit;
  text-decoration: none;
}

.kutby-announcement__link:hover,
.kutby-announcement__link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.kutby-header-stack {
  background: transparent;
}

@media (max-width: 767px) {
  .kutby-header__inner,
  .kutby-header__row {
    gap: var(--kutby-space-3);
    min-height: calc(var(--kutby-header-height, 64px) - 4px);
  }

  .kutby-header__utilities .kutby-header-search--form,
  .kutby-header-cta {
    display: none;
  }

  .kutby-nav {
    display: none;
    width: 100%;
    flex-basis: 100%;
    padding: var(--kutby-space-2) 0 var(--kutby-space-3);
  }

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

  .kutby-nav[hidden] {
    display: none !important;
  }

  .kutby-nav ul,
  .kutby-nav .kutby-menu {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    width: 100%;
    gap: 0.15rem;
  }

  .kutby-nav a {
    width: 100%;
    min-height: 2.75rem;
    padding-inline: 0.85rem;
    border-radius: var(--kutby-radius-md);
    font-size: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .kutby-header,
  .kutby-nav a,
  .kutby-header-cta {
    transition: none;
  }
}
