/* ==========================================
   ACERSMP SHARED NAVIGATION
   One header used by every page.
   Based on the Leaderboard header.
========================================== */

.site-header {
  --sh-bg: rgba(6, 12, 22, .88);
  --sh-bg-solid: rgba(6, 12, 22, .98);
  --sh-border: rgba(255, 255, 255, .07);
  --sh-text: #f3f7ff;
  --sh-muted: #8a9bb4;
  --sh-blue: #367dff;
  --sh-hover: rgba(54, 125, 255, .08);
  --sh-btn-bg: #101f33;
  --sh-btn-bg-hover: #172b45;
  --sh-btn-border: rgba(138, 155, 180, .2);

  position: sticky;
  top: 0;
  z-index: 1000;

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;

  width: 100%;
  min-height: 76px;
  padding: 14px max(20px, calc((100% - 1160px) / 2));

  border-bottom: 1px solid var(--sh-border);
  background: var(--sh-bg);

  font-family: Inter, ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;

  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

body.light-theme .site-header {
  --sh-bg: rgba(247, 251, 255, .92);
  --sh-bg-solid: rgba(247, 251, 255, .99);
  --sh-border: rgba(45, 76, 112, .16);
  --sh-text: #122238;
  --sh-muted: #61738a;
  --sh-blue: #1f6fd0;
  --sh-blue-bright: #0b5ec4;
  --sh-hover: rgba(54, 125, 255, .1);
  --sh-btn-bg: #ffffff;
  --sh-btn-bg-hover: #eaf2fc;
  --sh-btn-border: rgba(45, 76, 112, .22);
}

/*
 * .site-header is listed here on purpose, and it has to be.
 *
 * The page stylesheets scope their reset to their own wrapper, e.g.
 * ".profile-page *". The header is a SIBLING of that wrapper, not a
 * descendant, and the rule below only ever matched descendants. So
 * the header itself fell back to content-box.
 *
 * With content-box, `width: 100%` means the content is a full viewport
 * wide and the padding is then added on top:
 *
 *   1920px viewport  ->  header measured 2648px  ->  736px of sideways
 *   scroll, with the login button pushed off the right edge.
 *
 * This only ever bit the pages whose stylesheet scopes the reset to its
 * own wrapper instead of applying it globally - admin, profile and
 * support. The other pages declare a plain `* { box-sizing: border-box }`,
 * which reaches the header as well, so they were unaffected.
 */
.site-header,
.site-header *,
.site-header *::before,
.site-header *::after {
  box-sizing: border-box;
}

/* Brand: logo + ACERSMP text */

.site-header .sh-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;

  color: var(--sh-text);
  text-decoration: none;
  white-space: nowrap;

  font-size: 19px;
  font-weight: 900;
  letter-spacing: -.6px;
  line-height: 1;
}

.site-header .sh-brand img {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;

  border: 1px solid rgba(114, 165, 255, .35);
  border-radius: 12px;

  transition: transform .25s ease, box-shadow .25s ease,
    border-color .25s ease;
}

.site-header .sh-brand:hover img {
  transform: rotate(-4deg) scale(1.05);
  border-color: rgba(114, 165, 255, .8);
  box-shadow: 0 0 22px rgba(54, 125, 255, .35);
}

.site-header .sh-accent {
  color: var(--sh-blue);
}

/* Links */

.site-header .sh-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  margin-left: auto;
}

.site-header .sh-nav a {
  position: relative;
  padding: 10px 0;

  color: var(--sh-muted);
  text-decoration: none;
  white-space: nowrap;

  font-size: 13px;
  font-weight: 650;

  transition: color .2s ease;
}

.site-header .sh-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 3px;

  width: 100%;
  height: 2px;

  border-radius: 2px;
  background: var(--sh-blue);

  transform: scaleX(0);
  transform-origin: left;
  transition: transform .22s ease;
}

.site-header .sh-nav a:hover,
.site-header .sh-nav a.active {
  color: var(--sh-text);
}

.site-header .sh-nav a:hover::after,
.site-header .sh-nav a.active::after {
  transform: scaleX(1);
}

/* Right side: theme, hamburger, login */

.site-header .sh-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.site-header .sh-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-height: 42px;
  padding: 0 20px;

  border: 1px solid rgba(114, 165, 255, .35);
  border-radius: 10px;

  background: linear-gradient(135deg, #367dff, #245bdb);
  color: #fff;
  text-decoration: none;
  cursor: pointer;

  font: inherit;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;

  box-shadow: 0 5px 18px rgba(54, 125, 255, .18);

  transition: transform .2s ease, box-shadow .2s ease, filter .2s ease;
}

.site-header .sh-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 8px 24px rgba(54, 125, 255, .3);
}

/* ---------- Dark / light toggle (same icon style as Login) ---------- */

.site-header .sh-theme {
  position: relative;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  min-height: 42px;
  padding: 0 14px;

  border: 1px solid var(--sh-btn-border);
  border-radius: 10px;

  background: var(--sh-btn-bg);
  color: var(--sh-text);
  cursor: pointer;

  font: inherit;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;

  transition: background .2s ease, border-color .2s ease,
    color .2s ease, box-shadow .25s ease;
}

.site-header .sh-theme:hover {
  background: var(--sh-btn-bg-hover);
  border-color: rgba(114, 165, 255, .45);
  color: var(--sh-blue-bright, var(--sh-blue));
  box-shadow: 0 0 18px rgba(54, 125, 255, .22);
}

/* Both icons sit in the same grid cell and cross-fade.
   (Absolute positioning used to leave the moon on top of the label.) */

.site-header .sh-theme-icons {
  position: relative;

  display: grid;
  place-items: center;

  width: 19px;
  height: 19px;
  flex-shrink: 0;
}

.site-header .sh-theme-icon {
  grid-area: 1 / 1;

  display: block;

  width: 19px;
  height: 19px;

  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;

  transition: transform .45s cubic-bezier(.4, 1.5, .5, 1),
    opacity .28s ease;
}

/* Dark theme shows the sun (click for light) */

.site-header .sh-theme .sh-theme-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.site-header .sh-theme .sh-theme-moon {
  opacity: 0;
  transform: rotate(-70deg) scale(.4);
}

/* Light theme flips them */

.site-header .sh-theme[aria-pressed="true"] .sh-theme-sun {
  opacity: 0;
  transform: rotate(70deg) scale(.4);
}

.site-header .sh-theme[aria-pressed="true"] .sh-theme-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* ---------- Login / Logout button with icon ---------- */

.site-header .sh-auth-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.site-header .sh-auth-icon {
  width: 17px;
  height: 17px;
  display: block;

  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-header .sh-button[data-logged-in="true"] .sh-auth-icon {
  transition: transform .25s ease;
}

.site-header .sh-button[data-logged-in="true"]:hover .sh-auth-icon {
  transform: translateX(2px);
}

/* Hamburger: three CSS lines, always drawn (no font/icon needed) */

.site-header .sh-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;

  width: 42px;
  height: 42px;
  padding: 0;

  border: 1px solid var(--sh-btn-border);
  border-radius: 10px;

  background: var(--sh-btn-bg);
  cursor: pointer;

  transition: background .2s ease, border-color .2s ease;
}

.site-header .sh-toggle:hover {
  background: var(--sh-btn-bg-hover);
  border-color: rgba(114, 165, 255, .45);
}

.site-header .sh-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--sh-text);
  transition: transform .25s ease, opacity .2s ease;
}

.site-header.menu-open .sh-toggle span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.site-header.menu-open .sh-toggle span:nth-child(2) {
  opacity: 0;
}

.site-header.menu-open .sh-toggle span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Mobile */

@media (max-width: 850px) {
  .site-header {
    gap: 14px;
    padding-left: 20px;
    padding-right: 20px;
  }

  .site-header .sh-actions {
    margin-left: auto;
  }

  .site-header .sh-toggle {
    display: inline-flex;
  }

  .site-header .sh-nav {
    position: absolute;
    top: calc(100% + 1px);
    right: 16px;
    left: 16px;

    display: none;
    align-items: stretch;
    flex-direction: column;
    justify-content: flex-start;
    gap: 4px;

    margin: 0;
    padding: 12px;

    border: 1px solid var(--sh-border);
    border-radius: 14px;

    background: var(--sh-bg-solid);
    box-shadow: 0 18px 40px rgba(0, 0, 0, .3);

    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
  }

  .site-header.menu-open .sh-nav {
    display: flex;
  }

  .site-header .sh-nav a {
    display: block;
    padding: 12px;
    border-radius: 8px;
  }

  .site-header .sh-nav a:hover,
  .site-header .sh-nav a.active {
    background: var(--sh-hover);
  }

  .site-header .sh-nav a::after {
    display: none;
  }
}

@media (max-width: 480px) {
  .site-header {
    padding-left: 14px;
    padding-right: 14px;
  }

  .site-header .sh-brand {
    font-size: 17px;
    gap: 9px;
  }

  .site-header .sh-brand img {
    width: 38px;
    height: 38px;
  }

  .site-header .sh-button {
    padding: 0 14px;
  }

  .site-header .sh-theme {
    width: 42px;
    padding: 0;
  }

  .site-header .sh-theme .sh-theme-text {
    display: none;
  }

  .site-header .sh-button .sh-auth-text {
    display: none;
  }

  .site-header .sh-button {
    width: 42px;
    padding: 0;
  }
}

@media (max-width: 360px) {
  .site-header .sh-brand span:not(.sh-accent) {
    font-size: 15px;
  }
}
