/*
 * Site chrome (header + footer), shared by the Angular app shell and the server-rendered Insights
 * pages. One stylesheet and one markup contract (see api/public-header.js for the server twin and
 * src/app/public-header, src/app/footer for the Angular ones) so the two can never drift apart.
 * Keep selectors scoped to .public-header / .site-footer. Hidden on print: the scoresheet print
 * layout is measured to the pixel and must never gain site chrome.
 */
.public-header {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .25rem 1.5rem;
  width: min(calc(100% - 2.5rem), 1120px);
  min-height: 80px;
  margin: 0 auto;
  padding: 0;
  border-bottom: 1px solid #e5e8ed;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
}

.public-header-brandwrap {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
}

.public-header-brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  min-height: 44px;
}

.public-header-brand img {
  display: block;
  width: 190px;
  height: auto;
}

.public-header .beta-badge {
  padding: .2rem .55rem;
  border-radius: 999px;
  background: #333;
  color: #fff;
  font-size: .625rem;
  font-weight: 700;
  letter-spacing: .08em;
  line-height: 1.2;
}

.public-header nav {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  align-self: stretch;
  gap: .25rem 1.25rem;
}

/*
 * Author display rules (flex, below) would otherwise beat the UA's [hidden] styling, and Insights
 * does not load Bootstrap's global override. Used to hide the account slot from invited guests.
 */
.public-header [hidden] { display: none !important; }

/* Desktop / landscape: nav and account sit inline on the right. */
.public-header-menu {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  align-self: stretch;
  gap: .25rem 1.5rem;
  margin-left: auto;
}

/* The hamburger only exists in the compact layout below. */
.public-header-menu-toggle { display: none; }

.public-header nav a,
.public-header-account a,
.public-header-account button {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: .5rem .125rem;
  color: #4f5661;
  font: inherit;
  font-size: .875rem;
  font-weight: 650;
  text-decoration: none;
  white-space: nowrap;
}

.public-header nav a { position: relative; }

.public-header nav a:hover,
.public-header nav a[aria-current="page"] { color: #112747; }

/* Current page: a tab-style bar that sits on the header's bottom rule rather than a text underline. */
.public-header nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: #112747;
}

.public-header-account {
  display: flex;
  align-items: center;
  align-self: center;
  gap: .25rem 1rem;
}

.public-header-account button {
  border: 0;
  background: none;
  cursor: pointer;
}

.public-header-account a:hover,
.public-header-account button:hover { color: #112747; }

/* Primary account action ("Log in"): the one filled control in the chrome. */
.public-header-account .header-login {
  padding: .5rem 1rem;
  border-radius: 999px;
  background: #112747;
  color: #fff;
}

.public-header-account .header-login:hover,
.public-header-account .header-login[aria-current="page"] {
  background: #1d3a66;
  color: #fff;
}

.public-header a:focus-visible,
.public-header button:focus-visible {
  outline: 2px solid #112747;
  outline-offset: 3px;
  border-radius: 3px;
}

/*
 * Compact layout: phones, and tablets held in portrait. Same breakpoint family the app's own
 * full-bleed modal screens use, so "portrait handheld" means one thing everywhere. The nav and
 * account controls collapse behind a simple hamburger that opens a panel under the header row.
 */
@media (max-width: 640px), (max-width: 1080px) and (orientation: portrait) {
  .public-header {
    min-height: 64px;
    padding: .25rem 0;
    gap: 0;
  }

  .public-header-brand img { width: 150px; }

  .public-header-menu-toggle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-sizing: border-box;
    width: 44px;
    height: 44px;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: none;
    cursor: pointer;
  }

  .public-header-menu-toggle:hover { background: #f1f3f6; }

  .public-header-menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    border-radius: 2px;
    background: #112747;
    transition: transform .2s ease, opacity .15s ease;
  }

  .public-header.menu-open .public-header-menu-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .public-header.menu-open .public-header-menu-toggle span:nth-child(2) { opacity: 0; }
  .public-header.menu-open .public-header-menu-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /*
   * Closed by collapsing height, not display:none, so opening and closing both animate. The panel
   * is also visibility:hidden while closed (after the collapse finishes) so its links drop out of
   * the tab order and the accessibility tree.
   */
  .public-header-menu {
    display: flex;
    flex: 0 0 100%;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 0;
    margin: 0;
    max-height: 0;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    border-top: 1px solid transparent;
    transition:
      max-height .3s cubic-bezier(.4, 0, .2, 1),
      padding .3s cubic-bezier(.4, 0, .2, 1),
      opacity .2s ease,
      border-color .3s ease,
      visibility 0s linear .3s;
  }

  .public-header.menu-open .public-header-menu {
    max-height: 480px;
    padding: .25rem 0 .75rem;
    opacity: 1;
    visibility: visible;
    border-top-color: #e5e8ed;
    transition:
      max-height .3s cubic-bezier(.4, 0, .2, 1),
      padding .3s cubic-bezier(.4, 0, .2, 1),
      opacity .25s ease .05s,
      border-color .3s ease,
      visibility 0s;
  }

  .public-header nav {
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    gap: 0;
  }

  .public-header nav a,
  .public-header-account a,
  .public-header-account button {
    justify-content: flex-start;
    min-height: 48px;
    padding: .5rem .25rem;
    font-size: 1rem;
  }

  .public-header nav a[aria-current="page"] { font-weight: 800; }
  .public-header nav a[aria-current="page"]::after { content: none; }

  .public-header-menu,
  .public-header nav { align-self: auto; }

  .public-header-account {
    flex-direction: column;
    align-items: stretch;
    align-self: stretch;
    gap: 0;
  }

  .public-header-account .header-login {
    justify-content: center;
    margin-top: .25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .public-header-menu,
  .public-header.menu-open .public-header-menu,
  .public-header-menu-toggle span { transition: none; }
}

/* ---------- Footer ---------- */
.site-footer {
  box-sizing: border-box;
  width: min(calc(100% - 2.5rem), 1120px);
  margin: 3rem auto 0;
  padding: 2rem 0 2.5rem;
  border-top: 1px solid #e5e8ed;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #4f5661;
  line-height: 1.5;
  text-align: left;
}

.site-footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.75rem 3rem;
}

.site-footer-about { max-width: 360px; }

.site-footer-name {
  margin: 0 0 .35rem;
  color: #112747;
  font-size: 1rem;
  font-weight: 750;
}

.site-footer-about p:last-child {
  margin: 0;
  font-size: .875rem;
}

.site-footer-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem 3.5rem;
}

.site-footer-group h2 {
  margin: 0 0 .5rem;
  color: #112747;
  font-size: .75rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.site-footer-group ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer-group a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  color: #4f5661;
  font-size: .875rem;
  font-weight: 600;
  text-decoration: none;
}

.site-footer-group a:hover {
  color: #112747;
  text-decoration: underline;
  text-underline-offset: .3em;
}

.site-footer a:focus-visible {
  outline: 2px solid #112747;
  outline-offset: 3px;
  border-radius: 3px;
}

@media (max-width: 640px) {
  .site-footer { padding-top: 1.5rem; }
  .site-footer-groups { gap: 1.25rem 2.5rem; }
}

@media print {
  .public-header,
  .site-footer { display: none !important; }
}
