/* Shared header nav (help button + user dropdown) and help modal styles.
 * Assumes the page defines CSS variables --brand-primary, --brand-primary-hover,
 * --surface, --surface-alt, --border, --text, --text-muted, --text-subtle. */

:root {
  --app-shell-sticky-offset: 6.5rem;
}

/* Public application shell. The marketing site uses a 16px hero radius and
 * 2.25rem outer gutters; this carries those proportions into the app without
 * giving an operational header marketing-page height. */
.app-shell-header-wrap {
  width: 100%;
  padding: 1.25rem 2rem 0.75rem;
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(
    to bottom,
    var(--bg, #f0f0ec) 0,
    var(--bg, #f0f0ec) calc(100% - 0.75rem),
    transparent 100%
  );
}
.app-shell-header {
  width: min(100%, calc(1200px - 4rem));
  min-height: 4.5rem;
  margin: 0 auto;
  padding: 0.7rem 1.1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
  position: relative;
  top: auto;
  z-index: 1;
  border: 0;
  background: transparent;
  color: #fff;
  box-shadow: none;
  isolation: isolate;
  line-height: 1.2;
}
.app-shell-header::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: -1.25rem;
  left: 0;
  z-index: 0;
  background: linear-gradient(
    to bottom,
    var(--bg, #f0f0ec) 0,
    var(--bg, #f0f0ec) calc(100% - 2.5rem),
    transparent 100%
  );
  pointer-events: none;
}
.app-shell-header::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  background: linear-gradient(112deg, var(--brand-primary, #4a7c59) 0%, #4a7c59 56%, #3f7468 100%);
  box-shadow: 0 18px 32px -18px rgba(38,106,75,0.58), 0 7px 18px -12px rgba(31,48,36,0.28);
  pointer-events: none;
}
.app-shell-header > * {
  position: relative;
  z-index: 2;
}
.app-shell-header .brand {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  max-width: 100%;
  color: #fff;
  text-decoration: none;
}
.app-shell-header .brand:hover { color: #fff; }
.app-shell-header .brand img { width: 30px; height: 30px; filter: brightness(0) invert(1); }
.app-shell-header .brand .brand-name { font-family: 'Merriweather Sans', sans-serif; font-size: 1.2rem; font-weight: 600; }
.app-primary-nav {
  justify-self: center;
  display: flex;
  align-items: stretch;
  gap: 0.15rem;
  min-width: 0;
  padding: 0.2rem;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 999px;
  background: rgba(255,255,255,0.055);
}
.app-primary-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.45rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid transparent;
  border-radius: 999px;
  color: rgba(255,255,255,0.78);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.app-primary-nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.07);
}
.app-primary-nav-link:focus-visible {
  outline: 2px solid rgba(255,255,255,0.9);
  outline-offset: 2px;
}
.app-primary-nav-link[aria-current="page"] {
  color: #fff;
  border-color: rgba(255,255,255,0.13);
  background: rgba(255,255,255,0.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.07);
}
.app-nav-label-short { display: none; }
.app-nav-compact .app-nav-label-full { display: none; }
.app-nav-compact .app-nav-label-short { display: inline; }
.app-shell-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  min-width: 0;
  width: max-content;
  max-width: 100%;
}
.app-nav-measuring .app-shell-actions { max-width: none; }
.app-shell-actions > :not(.nav-user) { flex-shrink: 0; }
.nav-updates-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.app-shell-footer {
  width: min(calc(100% - 4.5rem), calc(1200px - 4.5rem));
  margin-right: auto;
  margin-left: auto;
}

.nav-help-btn { background: transparent; border: none; color: rgba(255,255,255,0.85); cursor: pointer; padding: 0.375rem; border-radius: 50%; transition: color 0.15s, background 0.15s; display: flex; align-items: center; justify-content: center; }
.nav-help-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }
.nav-tooltip { position: fixed; z-index: 300; width: max-content; max-width: calc(100vw - 1.5rem); padding-top: 0.5rem; box-sizing: border-box; }
.nav-tooltip > span { display: block; padding: 0.45rem 0.7rem; border: 1px solid var(--border, #d9d3c7); border-radius: 7px; background: var(--surface, #fff); color: var(--text-muted, #56586a); box-shadow: 0 4px 14px rgba(31,35,56,0.12); font-size: 0.75rem; font-weight: 500; line-height: 1.4; text-align: center; overflow-wrap: anywhere; }
body:has(.nav-updates-popover, .modal-backdrop, .nav-user.open) > .nav-tooltip { display: none; }
.nav-updates-link, .nav-saved-link { position: relative; display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 50%; color: rgba(255,255,255,0.85); text-decoration: none; transition: color 0.15s, background 0.15s; }
.nav-updates-link:hover, .nav-updates-link[aria-current="page"], .nav-saved-link:hover, .nav-saved-link[aria-current="page"] { color: #fff; background: rgba(255,255,255,0.1); }
.nav-saved-link svg { width: 21px; height: 21px; }
.nav-updates-link[hidden] { display: none; }
.nav-updates-badge { position: absolute; top: -0.18rem; right: -0.28rem; display: inline-flex; align-items: center; justify-content: center; min-width: 1rem; height: 1rem; padding: 0 0.24rem; border: 2px solid var(--brand-primary, #4a7c59); border-radius: 999px; background: #f4c95d; color: #263127; font-size: 0.58rem; font-weight: 800; line-height: 1; }
.nav-updates-badge[hidden] { display: none; }
.nav-updates-popover { position: absolute; top: calc(100% + 0.75rem); right: -0.4rem; z-index: 250; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.65rem; width: min(16rem, calc(100vw - 1.5rem)); padding: 0.85rem 0.85rem 0.85rem 0.95rem; box-sizing: border-box; border: 1px solid var(--border, #ddd); border-radius: 10px; background: var(--surface, #fff); color: var(--text, #222); box-shadow: 0 12px 30px rgba(31,35,56,0.2); animation: navUpdatesHintIn 0.16s ease-out; }
.nav-updates-popover::before { position: absolute; top: -0.4rem; right: 1rem; width: 0.7rem; height: 0.7rem; border-top: 1px solid var(--border, #ddd); border-left: 1px solid var(--border, #ddd); background: var(--surface, #fff); content: ''; transform: rotate(45deg); }
.nav-updates-popover[data-first-message-hint] { right: auto; }
.nav-updates-popover[data-first-message-hint]::before { left: calc(var(--message-hint-arrow) - 0.35rem); right: auto; }
.nav-updates-popover[data-first-message-hint] .nav-updates-popover-copy { min-height: 0; overflow-y: auto; overflow-wrap: anywhere; }
.nav-updates-popover-copy { min-width: 0; }
.nav-updates-popover strong { display: block; margin-bottom: 0.25rem; font-size: 0.82rem; line-height: 1.3; }
.nav-updates-popover span { display: block; color: var(--text-muted, #666); font-size: 0.75rem; line-height: 1.45; }
.nav-updates-popover-close { display: inline-flex; align-items: center; justify-content: center; width: 1.65rem; height: 1.65rem; margin: -0.25rem -0.25rem 0 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--text-subtle, #888); cursor: pointer; }
.nav-updates-popover-close:hover { background: var(--surface-alt, #f5f5f2); color: var(--text, #222); }
.nav-updates-popover-close:focus-visible { outline: 2px solid var(--brand-primary, #4a7c59); outline-offset: 1px; }
@keyframes navUpdatesHintIn { from { opacity: 0; transform: translateY(-0.25rem); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .nav-updates-popover { animation: none; } }

.nav-user { position: relative; font-size: 0.875rem; min-width: 0; }
.nav-user-btn { max-width: 100%; display: inline-flex; align-items: center; gap: 0.5rem; background: transparent; border: 1px solid rgba(255,255,255,0.18); border-radius: 999px; padding: 0.375rem 0.875rem 0.375rem 0.625rem; color: rgba(255,255,255,0.9); font: inherit; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.nav-user-btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.32); }
.nav-user-btn .email { min-width: 0; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-user-btn svg { flex-shrink: 0; }
.nav-user-btn .icon-user { width: 16px; height: 16px; }
.nav-user-btn .icon-menu { width: 20px; height: 20px; display: none; }
.nav-user-btn .chev-down { width: 12px; height: 12px; opacity: 0.7; }
.nav-user-menu { position: absolute; top: calc(100% + 0.5rem); right: 0; min-width: 200px; max-width: min(24rem, calc(100vw - 2rem)); white-space: nowrap; background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); padding: 0.375rem; display: none; z-index: 200; }
.nav-user.open .nav-user-menu { display: block; }
.nav-user-menu-header { white-space: normal; padding: 0.5rem 0.625rem 0.625rem; border-bottom: 1px solid var(--border); margin-bottom: 0.375rem; font-size: 0.75rem; color: var(--text-subtle); word-break: break-all; }
.nav-user-menu-item { display: flex; align-items: center; gap: 0.5rem; width: 100%; background: transparent; border: none; font: inherit; font-size: 0.875rem; color: var(--text); text-align: left; padding: 0.5rem 0.625rem; border-radius: 4px; cursor: pointer; text-decoration: none; box-sizing: border-box; }
.nav-user-menu-item:hover { background: var(--surface-alt); }

.modal-backdrop { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 1000; animation: siteNavFadeIn 0.15s ease-out; overscroll-behavior: contain; }
.modal-backdrop::before { content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none; background: rgba(0,0,0,0.4); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); transform: translateZ(0); will-change: backdrop-filter; }
.modal-backdrop.expert-modal-backdrop { animation: none; }
.modal-backdrop.expert-modal-backdrop::before { content: none; }
.expert-modal-background-blur { filter: blur(4px); }
.expert-modal-effect-layer { position: fixed; inset: 0; z-index: 999; pointer-events: none; background: rgba(0,0,0,0.4); transform: translateZ(0); will-change: opacity; animation: siteNavFadeIn 0.12s ease-out; }
.modal-backdrop.closing { animation: siteNavFadeOut 0.14s ease-in forwards; }
.modal-backdrop.expert-modal-backdrop.closing { animation: none; }
.expert-modal-effect-layer.closing { animation: siteNavFadeOut 0.12s ease-in forwards; }
body:has(> .modal-backdrop) { overflow: hidden; }
.modal { position: relative; z-index: 1; background: #fff; border-radius: 8px; padding: 1.5rem; max-width: 420px; width: calc(100% - 2rem); box-shadow: 0 10px 40px rgba(0,0,0,0.15); animation: siteNavPopIn 0.15s ease-out; }
.modal-backdrop.closing .modal { animation: siteNavPopOut 0.14s ease-in forwards; }
.modal label { display: block; font-size: 0.8125rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.modal input[type="text"], .modal input[type="email"] { width: 100%; padding: 0.5rem 0.625rem; border: 1px solid var(--border); border-radius: 4px; font-size: 0.9375rem; font-family: inherit; margin-bottom: 0.875rem; background: var(--surface); color: var(--text); box-sizing: border-box; }
.modal input:focus { outline: none; border-color: var(--brand-primary); }
.modal textarea { width: 100%; padding: 0.5rem 0.625rem; border: 1px solid var(--border); border-radius: 4px; font-size: 0.9375rem; font-family: inherit; margin-bottom: 0.875rem; background: var(--surface); color: var(--text); box-sizing: border-box; resize: vertical; min-height: 80px; }
.modal textarea:focus { outline: none; border-color: var(--brand-primary); }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }

.help-options { display: flex; flex-direction: column; gap: 0; margin-bottom: 0.875rem; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.help-option { display: flex; align-items: center; gap: 0.625rem; padding: 0.625rem 0.75rem; cursor: pointer; font-size: 0.9375rem; color: var(--text); transition: background 0.15s; }
.help-option:hover { background: rgba(74,124,89,0.04); }
.help-option.selected { background: rgba(74,124,89,0.08); }
.help-option .help-radio { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; transition: border-color 0.15s; }
.help-option.selected .help-radio { border-color: var(--brand-primary); }
.help-option.selected .help-radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-primary); }
.help-success { color: var(--text-muted); font-size: 0.9375rem; text-align: center; padding: 1rem 0; }

@keyframes siteNavFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes siteNavFadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes siteNavPopIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes siteNavPopOut { from { opacity: 1; transform: scale(1); } to { opacity: 0; transform: scale(0.98); } }
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal, .modal-backdrop.closing, .modal-backdrop.closing .modal { animation: none; }
  .expert-modal-effect-layer, .expert-modal-effect-layer.closing { opacity: 1; animation: none; }
}

@media (max-width: 600px) {
  .nav-user-btn { padding: 0.375rem 0.5rem; border-color: transparent; }
  .nav-user-btn .email, .nav-user-btn .chev-down, .nav-user-btn .icon-user { display: none; }
  .nav-user-btn .icon-menu { display: block; }
  .modal { padding: 1.25rem; }
  .modal-backdrop:has(#help-form) .modal, .modal-backdrop:has(.help-success) .modal { max-width: none; width: 100%; height: 100%; border-radius: 0; display: flex; flex-direction: column; }
  .modal-backdrop:has(#help-form) #help-form { flex: 1; display: flex; flex-direction: column; }
  .modal-backdrop:has(#help-form) #help-desc { flex: 1; }
  .modal-backdrop:has(#help-form) .modal-actions { margin-top: auto; }
}

@media (max-width: 800px) {
  :root { --app-shell-sticky-offset: 8.25rem; }
  .app-shell-header-wrap {
    display: contents;
  }
  .app-shell-header-wrap::before {
    content: none;
  }
  .app-shell-header {
    width: auto;
    min-height: 0;
    margin: 0.75rem 0.875rem 0.5rem;
    padding: 0.75rem 0.9rem 0.65rem;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.65rem 0.75rem;
    position: sticky;
    top: 0.75rem;
    z-index: 100;
    box-shadow: none;
  }
  .app-shell-header::before {
    top: -0.75rem;
    right: -0.875rem;
    left: -0.875rem;
  }
  .app-shell-header .brand {
    width: 100%;
  }
  .app-shell-actions { grid-column: 2; grid-row: 1; }
  .app-primary-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .app-primary-nav::-webkit-scrollbar { display: none; }
  .app-primary-nav-link { flex: 1 0 auto; min-height: 2.25rem; padding: 0.4rem 0.8rem; }
  .app-shell-footer { width: calc(100% - 2rem); }
}

@media (max-width: 1050px) {
  .app-shell-header .brand { gap: 0.5rem; }
  .app-shell-header:not([data-nav-fit]) .app-nav-label-full { display: none; }
  .app-shell-header:not([data-nav-fit]) .app-nav-label-short { display: inline; }
}

@media (max-width: 420px) {
  .app-shell-header { column-gap: 0.5rem; }
  .app-shell-header .app-shell-actions { gap: 0.125rem; }
  .app-shell-header .nav-cta { padding-right: 0.75rem; padding-left: 0.75rem; }
  .app-shell-header .brand { gap: 0.45rem; }
  .app-shell-header .brand img { width: 27px; height: 27px; }
  .app-shell-header .brand .brand-name { font-size: 1.05rem; }
  .app-primary-nav-link { font-size: 0.8125rem; }
}

@media (max-width: 360px) {
  .app-primary-nav-link { padding-right: 0.45rem; padding-left: 0.45rem; }
}
