/* Shared Account menu (components/account_menu.html). Reuses the app's button, panel, and focus styles. */

.account-menu {
  position: relative;
  margin-left: auto;
}

.account-toggle {
  gap: 10px;
}

/* The base button rule sets display, which would otherwise override the hidden attribute (no-JS fallback). */
.account-toggle[hidden] {
  display: none;
}

.account-caret {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid currentColor;
  transition: transform 0.15s ease;
}

.account-toggle[aria-expanded="true"] .account-caret {
  transform: rotate(180deg);
}

.account-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* No-JS fallback: the panel renders inline as a row of quiet buttons, like the former header controls. */
.account-menu:not(.is-enhanced) .account-items {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.account-menu:not(.is-enhanced) .account-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.account-menu:not(.is-enhanced) .account-item {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  font: 600 16px system-ui;
}

.account-menu:not(.is-enhanced) .account-separator {
  display: none;
}

/* Enhanced dropdown: opens below the button, right-aligned, above page content and the bottom navigation. */
.account-menu.is-enhanced .account-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  width: min(280px, calc(100vw - 36px));
  max-height: calc(100vh - 190px);
  max-height: calc(100dvh - 190px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 14px 34px #00000080;
}

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

.account-menu.is-enhanced .account-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font: 600 16px system-ui;
  text-align: left;
  overflow-wrap: anywhere;
}

.account-menu.is-enhanced .account-item:hover,
.account-menu.is-enhanced .account-item:focus-visible {
  background: #233342;
}

.account-menu .account-item[aria-current="page"] {
  color: var(--green);
}

.account-separator {
  height: 0;
  margin: 6px 8px;
  border: 0;
  border-top: 1px solid var(--edge);
}

.account-signout {
  margin: 0;
}

/* Support links beneath the login and registration forms (visually secondary, like About SharedUpkeep). */
.auth-support {
  margin: 4px 0 0;
  font-size: 15px;
}

.auth-support a,
.support-email a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  border-radius: 4px;
}

.auth-support a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.auth-support a:hover {
  color: var(--ink);
}

/* Help & Support page */
.support-email {
  margin: 20px 0 8px;
  font-size: 18px;
  font-weight: 600;
  user-select: text;
  overflow-wrap: anywhere;
}

.support-email a {
  color: var(--green);
}

.support-actions {
  margin: 16px 0 8px;
}

.support-guidance {
  margin: 24px 0 0;
  padding-left: 1.2em;
}

.support-guidance li + li {
  margin-top: 8px;
}

/* Signed-in headers keep the logo and the Account button on one row at every width.
   The brand name truncates with an ellipsis only if the fonts leave no room. */
header:has(.account-menu.is-enhanced) {
  flex-wrap: nowrap;
}

header:has(.account-menu.is-enhanced) .brand {
  flex: 1 1 auto;
}

header:has(.account-menu.is-enhanced) .brand .brand-copy {
  white-space: nowrap;
  overflow-wrap: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}

header:has(.account-menu.is-enhanced) .account-menu {
  flex: 0 0 auto;
}

/* Narrow phones: a slightly smaller logo, name, and toggle so the name rarely truncates. */
@media (max-width: 400px) {
  header:has(.account-menu.is-enhanced) {
    gap: 10px;
  }

  header:has(.account-menu.is-enhanced) .brand {
    gap: 10px;
  }

  header:has(.account-menu.is-enhanced) .brand-icon {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  header:has(.account-menu.is-enhanced) .brand .brand-copy {
    font-size: 17px;
  }

  .account-toggle {
    flex-shrink: 0;
    padding: 12px 10px;
    gap: 8px;
  }
}

/* Smallest phones (320px class): tighter spacing so "SharedUpkeep" still fits beside Account. */
@media (max-width: 360px) {
  header:has(.account-menu.is-enhanced),
  header:has(.account-menu.is-enhanced) .brand {
    gap: 8px;
  }

  header:has(.account-menu.is-enhanced) .brand-icon {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }

  .account-toggle {
    padding: 12px 8px;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .account-caret { transition: none; }
}
