/* ==========================================================================
   auth.css — the account parts every page shares: Sign in / Sign up in the
   header, the account menu, the sign-in dialog, the watchlist button on a
   company page, and the toast. auth.js drives all of it.
   ========================================================================== */

/* ---------- Header ---------- */
.header-nav .account {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  margin-left: 8px;
}

.header-nav .account .button-primary {
  color: var(--on-accent);
}

.header-nav [hidden] {
  display: none;
}

/* parts of a page meant for one state only, whatever display they use */
[data-signed-out][hidden],
[data-signed-in][hidden] {
  display: none;
}

/* Watchlist, with how many companies are on it */
.nav-watchlist {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-watchlist .count {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--gridline);
  color: var(--fg-2);
  font-size: 11px;
}

/* The avatar: initials in a circle */
.account-menu-wrap {
  position: relative;
  display: inline-flex;
}

.avatar {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--gridline);
  color: var(--fg);
  font-size: 11px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.avatar[aria-expanded="true"] {
  border-color: var(--fg);
}

/* ---------- The account menu ---------- */
.account-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  width: 260px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  font-size: 13px;
  text-align: left;
}

.account-menu[hidden] {
  display: none;
}

.menu-who {
  padding: 10px 10px 12px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.menu-email {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-plan {
  padding: 8px 10px 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.menu-plan > span {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--fg);
}

.menu-sub {
  font-size: 12px;
  color: var(--fg-3);
}

/* .header-nav a would colour these grey; the menu sets its own */
.header-nav .menu-pro,
.header-nav .menu-pro:hover {
  color: var(--on-accent);
}

.header-nav .menu-item {
  color: var(--fg);
}

.header-nav .menu-quiet {
  color: var(--fg-2);
}

.menu-pro {
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.menu-pro:hover {
  text-decoration: none;
  filter: brightness(1.08);
}

.menu-item {
  padding: 9px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg);
  font-size: 13px;
  text-align: left;
}

.menu-item:hover {
  background: var(--hover);
  text-decoration: none;
}

.menu-quiet {
  color: var(--fg-2);
}

.menu-rule {
  margin: 6px 0;
  border-top: 1px solid var(--border);
}

/* ---------- The dialog ---------- */
.auth-scrim {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 11, 14, 0.55);
}

.auth-scrim[hidden] {
  display: none;
}

body.auth-open {
  overflow: hidden;
}

.auth-panel {
  width: 100%;
  max-width: 420px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-panel-wide {
  max-width: 560px;
}

.auth-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.auth-head-text {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
  border-radius: var(--radius);
  background: var(--gridline);
  color: var(--fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-kicker {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-3);
}

.auth-title {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.auth-sub {
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg-2);
}

.auth-sub b {
  font-weight: 400;
  color: var(--fg);
}

.auth-close {
  flex: none;
  width: 32px;
  height: 32px;
  margin: -6px -6px 0 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-close:hover {
  background: var(--hover);
  color: var(--fg);
}

/* the email form, and the column of buttons on the other steps */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-label {
  font-size: 13px;
  color: var(--fg-2);
}

.auth-input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field);
  color: var(--fg);
  font-size: 15px;
  outline: none;
}

.auth-input:focus {
  border-color: var(--accent);
}

.auth-input[aria-invalid="true"] {
  border-color: var(--down);
}

.auth-input::placeholder {
  color: var(--fg-3);
}

.auth-primary,
.auth-secondary {
  height: 44px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.auth-primary {
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
}

.auth-primary:hover {
  filter: brightness(1.08);
}

.auth-secondary {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
}

.auth-secondary:hover {
  background: var(--hover);
  text-decoration: none;
}

.auth-small {
  height: 40px;
  padding: 0 16px;
}

.auth-ghost {
  height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-2);
  font-size: 13px;
  font-weight: 500;
}

.auth-ghost:hover {
  color: var(--fg);
}

.auth-g {
  width: 18px;
  height: 18px;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 11px;
  color: var(--fg-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.auth-hint {
  font-size: 12px;
  color: var(--fg-3);
  text-align: center;
}

.auth-hint.problem {
  color: var(--down);
}

.auth-or {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--fg-3);
}

.auth-or > span:not(:nth-child(2)) {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-foot {
  font-size: 12px;
  line-height: 1.5;
  color: var(--fg-3);
}

.auth-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 4px 2px;
  font-size: 13px;
  color: var(--fg-3);
}

.auth-resend {
  color: var(--fg-2);
}

.auth-link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg-2);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-link-button:hover {
  color: var(--fg);
}

.auth-link-accent {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
}

/* the stand-in for the email link, until the backend sends real ones */
.auth-proto {
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--fg-3);
}

/* picking companies */
.auth-pick {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-pick-icon {
  position: absolute;
  left: 12px;
  color: var(--fg-3);
  display: inline-flex;
}

.auth-pick-input {
  height: 40px;
  padding-left: 36px;
  font-size: 14px;
}

.auth-pick-input::-webkit-search-cancel-button {
  display: none;
}

.auth-chips {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.auth-chip {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-2);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.auth-chip:hover {
  color: var(--fg);
}

.auth-chip[aria-pressed="true"] {
  border-color: var(--fg);
  background: var(--fg);
  color: var(--bg);
}

.auth-chip[aria-pressed="true"]::before {
  content: "✓";
}

.auth-actions {
  flex-wrap: wrap;
  padding: 0;
}

.auth-buttons {
  display: flex;
  gap: 8px;
}

/* ---------- The company page: Watchlist and Share ---------- */
.company-actions .button {
  height: 36px;
  padding: 0 14px;
}

.company-actions .icon-only {
  width: 36px;
  padding: 0;
  color: var(--fg-2);
}

.watch-button .when-idle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.watch-button.watching {
  background: var(--gridline);
}

/* while the pointer is over it, Watching reads Remove */
.watch-button .when-hover {
  display: none;
}

.watch-button.watching:hover .when-idle,
.watch-button.watching:focus-visible .when-idle {
  display: none;
}

.watch-button.watching:hover .when-hover,
.watch-button.watching:focus-visible .when-hover {
  display: inline;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  transform: translate(-50%, 8px);
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--fg);
  color: var(--bg);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.toast a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Phone ---------- */
@media (max-width: 640px) {
  /* beside a search box the header keeps only the sign-up button or the
     avatar, as the mockups do; Companies and Calendar are a tap away on
     the landing page and in the breadcrumbs */
  .header-search + .header-nav > a,
  .header-search + .header-nav .sign-in {
    display: none;
  }

  .header-nav .account {
    gap: 10px;
    margin-left: 0;
  }

  .account-menu {
    right: -8px;
  }

  /* the dialog becomes a sheet from the bottom */
  .auth-scrim {
    align-items: flex-end;
    padding: 0;
  }

  .auth-panel,
  .auth-panel-wide {
    max-width: none;
    padding: 20px 16px 32px;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
  }

  .auth-chips {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
