/* Site header: the brand-blue bar in both themes, a left sidebar menu, and a search field that is an icon on phones.
   It sticks to the top. On phones it slides away while the visitor scrolls down and comes back on the first scroll up
   (header.js), because there it costs a tenth of the screen; on wider screens it stays in view. */

.site-header {
  --focus-ring: #ffffff;
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--brand);
  color: var(--on-brand);
}

@media (max-width: 767.98px) {
  .site-header--hidden {
    transform: translateY(-100%);
  }
}

@media (max-width: 767.98px) and (prefers-reduced-motion: no-preference) {
  .site-header {
    transition: transform .2s ease;
  }
}

.site-header__bar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: var(--header-height);
  padding: 0 8px;
}

.site-header__button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.site-header__button:hover {
  background-color: rgba(255, 255, 255, .1);
}

.site-header__button .icon,
.site-header__account .icon {
  width: 22px;
  height: 22px;
}

.site-header__menu-close,
.site-header.menu-is-open .site-header__menu-open {
  display: none;
}

.site-header.menu-is-open .site-header__menu-close {
  display: block;
}

.site-header__logo {
  display: block;
  flex-shrink: 0;
  margin-left: 4px;
}

.site-header__logo img {
  display: block;
  width: 156px;
  height: auto;
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.site-header__account {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  height: 44px;
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}

.site-header__account:hover {
  background-color: rgba(255, 255, 255, .1);
}

.site-search {
  position: relative;
  display: none;
  align-items: center;
}

.site-search__icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--on-brand-muted);
  pointer-events: none;
}

.site-search__input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 12px 0 40px;
  border: 1px solid var(--brand-field-border);
  border-radius: var(--radius);
  background-color: var(--brand-field);
  color: var(--on-brand);
  font: inherit;
  font-size: .9375rem;
}

.site-search__input::placeholder {
  color: var(--on-brand-muted);
  opacity: 1;
}

.site-search__cancel {
  flex-shrink: 0;
  height: 44px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: .9375rem;
  cursor: pointer;
}

.theme-toggle__sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle__moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle__sun {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__moon {
    display: none;
  }

  :root:not([data-theme="light"]) .theme-toggle__sun {
    display: block;
  }
}

@media (max-width: 767.98px) {
  .site-header__account-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .site-header.is-searching .site-header__button[data-menu-toggle],
  .site-header.is-searching .site-header__logo,
  .site-header.is-searching .site-header__actions {
    display: none;
  }

  .site-header.is-searching .site-search {
    display: flex;
    flex: 1;
    gap: 8px;
    padding-left: 8px;
  }

  .site-header.is-searching .site-search__icon {
    left: 20px;
  }
}

@media (max-width: 767.98px) {
  .site-header__actions .theme-toggle {
    display: none;
  }
}

@media (max-width: 389.98px) {
  .site-header__logo img {
    width: 144px;
  }
}

@media (max-width: 359.98px) {
  .site-header__logo img {
    width: 128px;
  }

  .site-header__button,
  .site-header__account {
    width: 40px;
    min-width: 40px;
  }
}

@media (min-width: 768px) {
  .site-header__bar {
    gap: 8px;
    padding: 0 16px;
  }

  .site-header__logo img {
    width: 184px;
  }

  .site-search {
    display: flex;
    flex: 1;
    max-width: 420px;
    margin-left: 16px;
  }

  .site-search__cancel,
  .site-header__search-open {
    display: none;
  }

  .site-header__actions {
    gap: 8px;
  }

  .site-header__account {
    height: 36px;
    max-width: 160px;
    padding: 0 16px;
    border: 1px solid rgba(255, 255, 255, .45);
    font-size: .875rem;
    font-weight: 500;
  }

  .site-header__account:hover {
    border-color: var(--on-brand);
  }

  .site-header__account .icon {
    display: none;
  }

  .site-header__account-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.site-menu {
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  z-index: 2;
  width: min(320px, 86vw);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px 28px 32px;
  background-color: var(--brand-deep);
  color: var(--on-brand);
  transform: translateX(-100%);
}

.site-menu__overlay {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 1;
  background-color: rgba(0, 0, 0, .5);
  opacity: 0;
}

.site-header.menu-is-open .site-menu {
  transform: none;
}

.site-header.menu-is-open .site-menu__overlay {
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  .site-menu {
    transition: transform .25s ease;
  }

  .site-menu__overlay {
    transition: opacity .25s ease;
  }
}

:root.has-menu-open {
  overflow: hidden;
}

.site-menu__group + .site-menu__group {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--brand-line);
}

.site-menu__theme {
  margin: -8px 0 18px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--brand-line);
}

.site-menu__theme {
  display: none;
}

@media (max-width: 767.98px) {
  .site-menu__theme {
    display: block;
  }
}

.site-menu__theme-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  padding: 7px 0;
  border: 0;
  background: transparent;
  color: var(--on-brand);
  font: inherit;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
}

.site-menu__theme-label {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-menu__theme-label .icon {
  width: 20px;
  height: 20px;
  color: var(--on-brand-muted);
}

.site-menu__switch {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background-color: var(--brand-field-border);
}

.site-menu__switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: #ffffff;
}

.site-menu__theme-switch[aria-checked="true"] .site-menu__switch {
  background-color: var(--brand-accent);
}

.site-menu__theme-switch[aria-checked="true"] .site-menu__switch::after {
  left: 21px;
}

@media (prefers-reduced-motion: no-preference) {
  .site-menu__switch,
  .site-menu__switch::after {
    transition: background-color .2s ease, left .2s ease;
  }
}

.site-menu__heading {
  margin: 0 0 8px;
  color: var(--brand-label);
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.site-menu__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-menu__list form {
  margin: 0;
}

.site-menu__link {
  display: block;
  width: 100%;
  padding: 7px 0;
  border: 0;
  background: transparent;
  color: var(--on-brand);
  font: inherit;
  font-size: 1rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.site-menu__link:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.aci-notifications {
  position: relative;
}

.aci-notifications-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background-color: var(--badge);
  color: #ffffff;
  font-size: .65rem;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.aci-notifications-dropdown {
  position: fixed;
  top: 70px;
  right: 15px;
  z-index: 60;
  width: 320px;
  max-width: 90vw;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface);
  color: var(--text);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .18), 0 2px 6px rgba(0, 0, 0, .08);
  visibility: hidden;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity .15s ease, transform .15s ease, visibility 0s .15s;
}

.aci-notifications-dropdown.aci-open {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition: opacity .15s ease, transform .15s ease;
}

.aci-notifications-header {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
}

.aci-notifications-header-title {
  display: block;
  font-size: 1rem;
  font-weight: 600;
}

.aci-notifications-header-subtitle {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: .78rem;
}

.aci-notifications-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px 16px;
  color: var(--text-muted);
  font-size: .85rem;
  text-align: center;
}

.aci-notifications-empty-icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.aci-notifications-list {
  max-height: 340px;
  margin: 0;
  padding: 4px 0;
  overflow-y: auto;
  list-style: none;
}

.aci-notifications-item + .aci-notifications-item {
  border-top: 1px solid var(--border);
}

.aci-notifications-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text);
  text-decoration: none;
  transition: background-color .15s;
}

.aci-notifications-link:hover,
.aci-notifications-link:focus {
  background-color: var(--bg);
}

.aci-notifications-icon {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--accent-soft);
}

.aci-notifications-icon svg {
  width: 16px;
  height: 16px;
  fill: var(--accent);
}

.aci-notifications-text {
  flex: 1;
  font-size: .88rem;
  font-weight: 600;
}

.aci-notifications-pill {
  flex-shrink: 0;
  min-width: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background-color: var(--accent-soft);
  color: var(--accent);
  font-size: .78rem;
  font-weight: 700;
  text-align: center;
}

@media (max-width: 575px) {
  .aci-notifications-dropdown {
    top: calc(var(--header-height) + 8px);
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
  }

  .aci-notifications-list {
    max-height: calc(100vh - 180px);
  }
}

/* Signed in: the name (the person icon on mobile) opens a small account menu. Gold marks a subscriber. */
.account-menu {
  position: relative;
}

button.site-header__account {
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.site-header__account-chevron {
  display: none;
}

.account-menu__panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  width: 260px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface);
  box-shadow: var(--shadow-hover);
  color: var(--text);
}

.account-menu__panel[hidden] {
  display: none;
}

.account-menu__who {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--border);
}

.account-menu__name {
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu__subscriber {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  background: linear-gradient(90deg, var(--premium-from), var(--premium-to) 60%, var(--premium-from));
  -webkit-background-clip: text;
  background-clip: text;
  color: var(--premium);
  font-size: .875rem;
  font-weight: 700;
  letter-spacing: .02em;
  -webkit-text-fill-color: transparent;
}

.account-menu__subscriber .icon {
  width: 14px;
  height: 14px;
  color: var(--premium);
}

.account-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .9375rem;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.account-menu__item:hover,
.account-menu__item:focus-visible {
  background-color: var(--surface-2);
}

.account-menu__item .icon {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.account-menu__item--subscribe,
.account-menu__item--subscribe .icon {
  color: var(--link);
  font-weight: 600;
}

.account-menu__rule {
  margin: 6px 4px;
  border: 0;
  border-top: 1px solid var(--border);
}

@media (min-width: 768px) {
  button.site-header__account {
    padding: 0 12px 0 16px;
    border: 1px solid rgba(255, 255, 255, .45);
  }

  .site-header__account .site-header__account-chevron {
    display: block;
    width: 16px;
    height: 16px;
  }
}
