/* The header bar on every public page: logo, main menu, Discord link, account
   link and the phone menu. Below 760px it shares one layout with the top bars
   of the dashboard (dashboard/css/shell.css) and the operator panel (operator/css/base/small-screens.css). */

@layer layout {
  .site-header {
    height: 92px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    position: relative;
    width: 100%;
    padding-inline: max(24px, calc((100% - 1200px) / 2));
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
  }

  .brand {
    display: inline-flex;
    flex: none;
    align-items: center;
    font-size: 23px;
    font-weight: 700;
    letter-spacing: -0.6px;
    white-space: nowrap;
    line-height: 1;
  }

  /* Logos are sized by one dimension only. The ratio, no max-width and
     object-fit keep a narrow box (Safari's flex sizing) from squashing them. */
  .brand-logo {
    display: block;
    width: auto;
    max-width: none;
    height: 48px;
    aspect-ratio: 720 / 156;
    object-fit: contain;
  }

  .brand > span {
    font-weight: 500;
    color: var(--accent);
  }

  .desktop-nav,
  .header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .desktop-nav,
  .account-link {
    font-size: 13px;
    font-weight: 500;
  }

  .desktop-nav a:hover {
    color: var(--accent-hover);
  }

  .account-link {
    white-space: nowrap;
    border: 1px solid var(--border-warm);
    padding: 10px 14px;
    border-radius: 7px;
    color: var(--accent);
    background: var(--nav-selected);
    min-height: 42px;
  }

  .account-link span {
    margin-left: 9px;
  }

  .menu-toggle {
    display: none;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--bg-elevated);
    color: var(--text-primary);
  }

  .menu-toggle:hover {
    border-color: var(--border-warm);
    color: var(--accent);
  }

  .menu-toggle .icon-close,
  .menu-toggle[aria-expanded="true"] .icon-menu {
    display: none;
  }

  .menu-toggle[aria-expanded="true"] .icon-close {
    display: block;
  }

  .mobile-menu {
    position: absolute;
    top: calc(100% + 8px);
    inset-inline: 20px;
    z-index: 5;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    border-radius: 10px;
    padding: 10px;
    box-shadow: var(--frame-shadow);
  }

  .mobile-menu a {
    display: block;
    padding: 12px;
    font-size: 13px;
    border-radius: 7px;
  }

  .header-actions > .text-link {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding-inline: 6px;
  }
}

@layer components {
  .desktop-nav {
    margin-right: auto;
    padding-left: 20px;
    border-left: 1px solid var(--border-hover);
  }

  .header-socials {
    display: flex;
    align-items: center;
    padding-right: 10px;
    border-right: 1px solid var(--border);
  }

  .social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 7px;
    color: var(--text-secondary);
    transition: color 150ms ease;
  }

  .social-link .ui-icon {
    width: 22px;
    height: 22px;
  }

  .social-link:is(:hover, :focus-visible) {
    color: var(--accent);
  }

  .desktop-nav a {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 7px;
    color: var(--text-secondary);
  }

  .desktop-nav .ui-icon {
    color: var(--accent);
  }

  .desktop-nav a:hover,
  .mobile-menu a:hover,
  .account-link:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
    border-color: var(--border-warm);
  }
}

@layer responsive {
  @media (max-width: 1100px) {
    .site-header {
      gap: 16px;
    }

    .desktop-nav {
      gap: 2px;
      padding-left: 14px;
    }

    .desktop-nav a {
      gap: 6px;
      padding-inline: 9px;
    }
  }

  @media (max-width: 800px) {
    .site-header {
      height: 76px;
      padding-inline: 20px;
    }

    .brand-logo {
      height: 40px;
    }

    .desktop-nav {
      display: none;
    }

    .menu-toggle {
      display: grid;
    }

    .header-actions {
      gap: 15px;
    }
  }

  @media (max-width: 520px) {
    .header-socials {
      display: none;
    }

    .brand-logo {
      height: 36px;
    }

    .account-link {
      font-size: 11px;
      padding: 9px 10px;
    }

    .account-link span {
      margin-left: 8px;
    }
  }

  /* Narrow desktops (iPad portrait): the nav drops its icons so the header
     fits beside the account button. */
  @media (max-width: 960px) {
    .desktop-nav .ui-icon {
      display: none;
    }
  }

  @media (max-width: 860px) {
    .brand-logo {
      height: 40px;
    }
  }

  /* Phones: one header layout on every page (64px bar, 44px logo, 40px
     controls on the logo's centre line), shared with the dashboard and the
     operator panel's top rows. */
  @media (max-width: 760px) {
    .site-header {
      height: 64px;
      padding-inline: 16px;
    }

    .site-header .brand-logo {
      height: 36px;
    }

    .site-header .header-actions {
      gap: 10px;
    }

    .site-header :is(.account-link, .menu-toggle, .text-link, .social-link) {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      height: 40px;
      min-height: 40px;
      padding-block: 0;
      white-space: nowrap;
    }

    .site-header .menu-toggle {
      width: 40px;
    }

    .site-header .mobile-menu {
      inset-inline: 16px;
    }
  }

  @media (max-width: 340px) {
    .site-header .brand-logo {
      height: 30px;
    }
  }
}
