/* --------------------------------------------------------------------------
   TbsRace layout: page shell, header, navigation and responsive containers.
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(18px, 4vw, 40px);
}

.container-narrow {
  max-width: 940px;
}

.page {
  padding-block: clamp(26px, 4vw, 46px) clamp(56px, 8vw, 96px);
}

.page-heading {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: clamp(22px, 3vw, 34px);
}

.page-heading-copy {
  max-width: 720px;
}

.page-heading h1 {
  margin-top: 5px;
}

.page-lede {
  max-width: 62ch;
  margin-top: 10px;
  color: var(--muted);
  font-size: clamp(0.92rem, 1.4vw, 1.02rem);
  line-height: 1.6;
}

@media (min-width: 900px) {
  .page-heading {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 80;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 10, 9, 0.82);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  backdrop-filter: blur(18px) saturate(130%);
}

.site-header-inner {
  position: relative;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: var(--header-h);
  padding-block: 10px;
}

.brand {
  display: inline-flex;
  align-items: center;
  flex: none;
  min-height: 44px;
  font-family: var(--font-display);
  font-size: 1.34rem;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1;
}

.brand-tbs {
  color: var(--text);
}

.brand-race {
  color: var(--gold);
}

.brand-large {
  font-size: clamp(1.7rem, 3vw, 2.2rem);
}

.site-header-auth .site-header-inner {
  justify-content: center;
}

.site-header-auth .brand {
  font-size: 1.55rem;
}

/* --------------------------------------------------------------------------
   Desktop navigation
   -------------------------------------------------------------------------- */

.main-nav {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-inline: auto;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 13px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition:
    color 160ms var(--ease),
    background-color 160ms var(--ease);
}

.nav-link:hover {
  color: var(--text);
  background: rgba(244, 237, 225, 0.05);
}

.nav-link.is-active {
  color: var(--gold);
  background: var(--gold-wash);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.menu-toggle {
  display: none;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(244, 237, 225, 0.03);
}

.menu-toggle-lines {
  display: grid;
  gap: 4px;
  width: 18px;
}

.menu-toggle-lines span {
  display: block;
  height: 1.5px;
  border-radius: 2px;
  background: var(--text);
  transition: transform 180ms var(--ease), opacity 180ms var(--ease);
}

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

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

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

.nav-scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: block;
  width: 100%;
  /* The backdrop-filter on .site-header makes it the containing block for
     fixed children, so 100% would only cover the header. */
  height: 100vh;
  height: 100dvh;
  border: 0;
  background: rgba(0, 0, 0, 0.58);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

/* --------------------------------------------------------------------------
   Account menu
   -------------------------------------------------------------------------- */

.user-menu {
  position: relative;
}

.avatar-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-gold);
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 20%, rgba(233, 201, 95, 0.24), transparent 60%),
    var(--card-soft);
  color: var(--gold-bright);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: border-color 160ms var(--ease), transform 160ms var(--ease);
}

.avatar-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-button .avatar-photo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.avatar-button:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 90;
  width: min(260px, calc(100vw - 32px));
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #17150f;
  box-shadow: var(--shadow);
}

.user-dropdown-head {
  display: grid;
  gap: 2px;
  padding: 10px 12px 12px;
}

.user-dropdown-name {
  overflow: hidden;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-class {
  color: var(--muted);
  font-size: 0.76rem;
}

.dropdown-divider {
  height: 1px;
  margin: 2px 8px 6px;
  background: var(--line);
}

.dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: 0.88rem;
  text-align: left;
}

.dropdown-item:hover {
  background: rgba(244, 237, 225, 0.06);
}

.dropdown-item[data-sign-out]:hover {
  color: var(--coral);
  background: var(--coral-wash);
}

/* --------------------------------------------------------------------------
   Mobile navigation
   -------------------------------------------------------------------------- */

@media (max-width: 860px) {
  :root {
    --header-h: 64px;
  }

  .site-header-inner {
    gap: 12px;
  }

  .brand {
    font-size: 1.2rem;
  }

  .main-nav {
    position: fixed;
    top: var(--header-h);
    right: 0;
    left: 0;
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    margin: 0;
    padding: 14px clamp(18px, 4vw, 28px) calc(22px + env(safe-area-inset-bottom));
    border-bottom: 1px solid var(--line-strong);
    background: #0f0e0b;
    box-shadow: 0 28px 50px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition:
      opacity 180ms var(--ease),
      transform 180ms var(--ease),
      visibility 180ms;
  }

  .site-header.nav-open .main-nav {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .nav-link {
    min-height: 48px;
    padding: 12px 16px;
    border-radius: var(--radius-xs);
    font-size: 1rem;
  }

  .menu-toggle {
    display: grid;
  }

  .header-actions {
    gap: 6px;
  }

  body.nav-open {
    overflow: hidden;
  }
}

@media (max-width: 380px) {
  .page {
    padding-top: 22px;
  }

  .brand {
    font-size: 1.1rem;
  }
}
