/*
 * BF shared shell
 * Keeps the public header, footer, system messages and error states consistent.
 * Page-specific layouts remain owned by their existing component stylesheets.
 */

.bf-skip-link {
  position: fixed;
  top: 10px;
  left: 12px;
  z-index: 5000;
  transform: translateY(-160%);
  min-height: 44px;
  box-sizing: border-box;
  padding: 10px 16px;
  border: 2px solid #fff;
  border-radius: 10px;
  background: #071a33;
  color: #fff;
  font-weight: 900;
  text-decoration: none;
  box-shadow: 0 8px 24px rgba(7, 26, 51, .28);
  transition: transform .16s ease;
}

.bf-skip-link:focus {
  transform: translateY(0);
  outline: 3px solid var(--bf-focus, #f6c344);
  outline-offset: 3px;
}

.site-header.bf-site-header {
  border-bottom-width: 3px;
  box-shadow: 0 8px 24px rgba(7, 26, 51, 0.2);
}

.bf-site-header .header-inner {
  width: min(100%, 1440px);
  max-width: 1440px;
  height: 78px;
  min-height: 78px;
  margin-inline: auto;
  padding-inline: clamp(16px, 2.2vw, 30px);
}

.bf-site-header .logo-link {
  min-width: 0;
  gap: 11px;
  border-radius: 12px;
}

.bf-site-header .site-logo-img {
  width: auto;
  height: 58px;
  border-radius: 13px;
  border-width: 2px;
}

.bf-site-header .site-title {
  min-width: 0;
  font-size: clamp(1.05rem, 1.45vw, 1.28rem);
  letter-spacing: 0.02em;
}

.bf-site-header .main-nav {
  gap: 4px;
}

.bf-site-header :where(.nav-link, .nav-dropdown-toggle, .nav-global-search, .nav-btn-login, .nav-user-toggle) {
  min-height: 44px;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
}

.bf-site-header :where(.nav-link, .nav-dropdown-toggle) {
  display: inline-flex;
  padding: 8px 11px;
}

.bf-site-header .nav-btn-login {
  display: inline-flex;
  padding: 9px 15px;
}

.bf-site-header .nav-dropdown-menu {
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(7, 26, 51, 0.24);
}

.bf-site-header :where(a, button):focus-visible,
.site-footer.bf-site-footer :where(a, summary):focus-visible,
.line-float :where(a, button):focus-visible {
  outline: 3px solid var(--bf-focus, #f6c344);
  outline-offset: 3px;
}

.site-footer.bf-site-footer {
  width: min(calc(100% - 32px), 1160px);
  box-sizing: border-box;
  margin: clamp(28px, 5vw, 54px) auto 0;
  padding: 28px 18px 34px;
  border-top: 1px solid rgba(100, 116, 139, 0.28);
}

.site-footer.bf-site-footer p {
  color: var(--bf-text-muted, #64748b);
  line-height: 1.75;
}

.site-footer.bf-site-footer .footer-nav {
  max-width: 980px;
  margin: 12px auto 0;
}

.site-footer.bf-site-footer :where(.footer-primary, .footer-more-links) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 12px;
}

.site-footer.bf-site-footer .footer-primary a {
  color: var(--bf-brand-700, #1d4ed8);
  font-weight: 850;
}

.site-footer.bf-site-footer .footer-more {
  margin-top: 8px;
}

.site-footer.bf-site-footer .footer-more summary {
  display: none;
}

.site-footer.bf-site-footer .footer-more:not([open]) > .footer-more-links {
  display: flex;
}

.site-footer.bf-site-footer .footer-more-links a {
  color: var(--bf-text-muted, #64748b);
  font-size: .78rem;
}

.site-footer.bf-site-footer .footer-nav a {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 5px 7px;
  border-radius: 8px;
  text-underline-offset: 3px;
}

body.dark-mode .site-footer.bf-site-footer {
  border-top-color: rgba(148, 163, 184, 0.24);
}

body.dark-mode .site-footer.bf-site-footer p {
  color: var(--bf-text-muted, #a8b6cb);
}

.line-float :where(a, .theme-toggle-btn) {
  min-width: 46px;
  min-height: 46px;
  box-sizing: border-box;
}

/* Public empty, filtered and login-required states. */
main :where(
  .team-empty-state,
  .inventory-empty,
  .shop-no-results,
  .market-empty-filter,
  .conversation-empty-filter,
  .nfp-empty,
  .pfv-empty,
  .contact-empty-reports
),
.site-main > .empty-state,
.raffles-page .empty-state {
  box-sizing: border-box;
  border: 1px dashed var(--bf-border-strong, rgba(29, 78, 216, 0.28));
  border-radius: var(--bf-radius-card, 16px);
  padding: clamp(22px, 4vw, 34px);
  background: color-mix(in srgb, var(--bf-surface-soft, #f7fbff) 94%, transparent);
  color: var(--bf-text-muted, #64748b);
  line-height: 1.7;
}

main :where(.team-create-login, p.form-login-hint, .login-prompt) {
  box-sizing: border-box;
  border: 1px solid var(--bf-border-strong, rgba(29, 78, 216, 0.28));
  border-radius: var(--bf-radius-card, 16px);
  padding: 18px 20px;
  background: var(--bf-surface-soft, #f7fbff);
  color: var(--bf-text, #102a43);
  line-height: 1.7;
}

main :where(.team-create-login, p.form-login-hint, .login-prompt) a {
  font-weight: 850;
  text-underline-offset: 3px;
}

/* Branded 404 / system page. */
.system-page {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, var(--bf-page-bg-top, #eef8ff), var(--bf-page-bg-bottom, #d9edff));
  color: var(--bf-text, #102a43);
}

.system-page .sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.system-page .system-main {
  display: grid;
  width: min(calc(100% - 32px), 980px);
  min-height: min(620px, calc(100vh - 250px));
  margin-inline: auto;
  padding: clamp(42px, 8vw, 86px) 0;
  place-items: center;
}

.system-page .system-state {
  width: min(100%, 720px);
  box-sizing: border-box;
  padding: clamp(28px, 6vw, 52px);
  border: 1px solid var(--bf-border, rgba(15, 42, 86, 0.14));
  border-radius: var(--bf-radius-hero, 20px);
  background: var(--bf-surface, #fff);
  box-shadow: var(--bf-shadow-raised, 0 16px 38px rgba(15, 42, 86, 0.13));
  text-align: center;
}

.system-page .system-state-code {
  display: inline-flex;
  min-width: 82px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  padding: 6px 18px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1e3a8a;
  font-size: 1.05rem;
  font-weight: 950;
  letter-spacing: 0.12em;
}

.system-page .system-state h1 {
  margin: 0;
  color: var(--bf-brand-950, #071a33);
  font-size: clamp(2rem, 7vw, 3.35rem);
  line-height: 1.1;
}

.system-page .system-state > p {
  max-width: 560px;
  margin: 16px auto 0;
  color: var(--bf-text-muted, #64748b);
  font-size: 1rem;
  line-height: 1.75;
}

.system-page .system-state-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 24px;
}

.system-page .system-state-actions a {
  display: inline-flex;
  min-height: 44px;
  box-sizing: border-box;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: 1px solid var(--bf-border-strong, rgba(29, 78, 216, 0.28));
  border-radius: var(--bf-radius-control, 10px);
  background: var(--bf-surface, #fff);
  color: var(--bf-brand-700, #1d4ed8);
  font-weight: 900;
  text-decoration: none;
}

.system-page .system-state-actions a:first-child {
  border-color: var(--bf-brand-700, #1d4ed8);
  background: var(--bf-brand-700, #1d4ed8);
  color: #fff;
}

.system-page .system-search {
  display: flex;
  width: min(100%, 480px);
  margin: 18px auto 0;
  gap: 8px;
}

.system-page .system-search input,
.system-page .system-search button {
  min-height: 44px;
  box-sizing: border-box;
  border-radius: var(--bf-radius-control, 10px);
  font: inherit;
}

.system-page .system-search input {
  min-width: 0;
  flex: 1 1 auto;
  padding: 10px 13px;
  border: 1px solid var(--bf-border-strong, rgba(29, 78, 216, 0.28));
  background: var(--bf-surface, #fff);
  color: var(--bf-text, #102a43);
}

.system-page .system-search button {
  flex: 0 0 auto;
  padding: 10px 16px;
  border: 1px solid var(--bf-brand-900, #0f2a56);
  background: var(--bf-brand-900, #0f2a56);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}

.system-page :where(a, input, button):focus-visible {
  outline: 3px solid var(--bf-focus, #f6c344);
  outline-offset: 3px;
}

body.dark-mode.system-page .system-state-code {
  background: rgba(37, 99, 235, 0.24);
  color: #bfdbfe;
}

body.dark-mode.system-page .system-state h1 {
  color: var(--bf-text, #e5edf8);
}

@media (max-width: 1100px) {
  .bf-site-header .header-inner {
    height: 72px;
    min-height: 72px;
    padding-inline: 14px;
  }

  .bf-site-header .site-logo-img {
    height: 52px;
  }

  .bf-site-header .nav-toggle {
    display: flex;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    padding: 8px;
    border-radius: 11px;
  }

  .bf-site-header .main-nav {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    width: 100%;
    max-width: none;
    max-height: min(72vh, 640px);
    padding: 14px max(14px, env(safe-area-inset-right)) calc(22px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0 0 18px 18px;
    box-shadow: 0 18px 34px rgba(7, 26, 51, 0.34);
  }

  .bf-site-header :where(.nav-link, .nav-dropdown-toggle, .nav-global-search, .nav-btn-login, .nav-user-toggle) {
    width: 100%;
    min-height: 44px;
    margin-left: 0;
    box-sizing: border-box;
  }

  .bf-site-header .nav-btn-login {
    display: flex;
    margin-top: 8px;
  }
}

@media (max-width: 480px) {
  .bf-site-header .header-inner {
    height: 68px;
    min-height: 68px;
    padding-inline: 12px;
  }

  .bf-site-header .site-logo-img {
    height: 48px;
  }

  .bf-site-header .site-title {
    display: block;
    max-width: min(48vw, 190px);
    overflow: hidden;
    font-size: 0.94rem;
    letter-spacing: 0;
    text-overflow: ellipsis;
  }

  .site-footer.bf-site-footer {
    width: min(calc(100% - 24px), 1160px);
    padding: 18px 10px calc(22px + env(safe-area-inset-bottom));
  }

  .site-footer.bf-site-footer .footer-disclaimer {
    font-size: .78rem;
    line-height: 1.6;
  }

  .site-footer.bf-site-footer .footer-tagline {
    display: none;
  }

  .site-footer.bf-site-footer .footer-primary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .site-footer.bf-site-footer .footer-primary a {
    min-height: 44px;
    padding: 7px 5px;
    border: 1px solid var(--bf-border, rgba(15, 42, 86, .14));
    background: var(--bf-surface-soft, #f7fbff);
    font-size: .75rem;
    text-decoration: none;
  }

  .site-footer.bf-site-footer .footer-more {
    margin-top: 10px;
  }

  .site-footer.bf-site-footer .footer-more summary {
    display: flex;
    min-height: 44px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
    padding: 8px 12px;
    border: 1px solid var(--bf-border, rgba(15, 42, 86, .14));
    border-radius: 10px;
    background: var(--bf-surface, #fff);
    color: var(--bf-text, #102a43);
    font-size: .78rem;
    font-weight: 850;
    cursor: pointer;
    list-style: none;
  }

  .site-footer.bf-site-footer .footer-more summary::-webkit-details-marker {
    display: none;
  }

  .site-footer.bf-site-footer .footer-more[open] summary span {
    transform: rotate(180deg);
  }

  .site-footer.bf-site-footer .footer-more:not([open]) > .footer-more-links {
    display: none;
  }

  .site-footer.bf-site-footer .footer-more-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 8px 4px 0;
  }

  .site-footer.bf-site-footer .footer-more-links a {
    min-height: 40px;
    font-size: .72rem;
    text-decoration: none;
  }

  .line-float {
    right: max(12px, env(safe-area-inset-right));
    bottom: max(78px, calc(14px + env(safe-area-inset-bottom)));
  }

  .system-page .system-main {
    width: min(calc(100% - 24px), 980px);
    padding-block: 34px 48px;
  }

  .system-page .system-state {
    padding: 28px 18px;
  }

  .system-page .system-state-actions,
  .system-page .system-search {
    flex-direction: column;
  }

  .system-page .system-state-actions a,
  .system-page .system-search button {
    width: 100%;
  }
}

@media (max-width: 350px) {
  .bf-site-header .site-title {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bf-site-header *,
  .line-float * {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
