.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 76px;
  background: rgba(252, 253, 255, 0.96);
  border-bottom: 1px solid var(--matths-line);
  backdrop-filter: blur(12px);
}

.site-header .container {
  width: min(1180px, calc(100% - 48px));
  margin-inline: auto;
}

.site-header .navbar {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-header .brand {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  text-decoration: none;
}

.site-header .brand-logo {
  width: 132px;
  height: auto;
  display: block;
  flex: 0 0 132px;
}

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

.site-header .nav-links a,
.site-header .nav-cluster summary,
.site-header .login-link {
  position: relative;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--matths-muted);
  font-size: 14px;
  font-weight: 680;
  text-decoration: none;
}

.site-header .nav-arena-link,
.site-header .nav-cluster summary,
.site-header .login-link {
  padding-inline: 10px;
  border-radius: 11px;
  transition:
    color var(--motion-fast, 120ms) var(--motion-ease, ease),
    background-color var(--motion-fast, 120ms) var(--motion-ease, ease);
}

.site-header .login-link {
  min-width: 44px;
  justify-content: center;
}

.site-header .nav-links a:hover,
.site-header .nav-links a.active,
.site-header .login-link:hover {
  color: var(--matths-ink);
}

.site-header .nav-cluster summary:hover,
.site-header .nav-cluster[open] summary {
  color: var(--matths-ink);
  background: #f2f4fa;
}

.site-header .nav-cluster.active summary {
  color: var(--matths-violet-text, #6240cf);
  background: var(--matths-primary-soft, #edf1ff);
}

/*
 * 각 페이지의 기존 내비 CSS가 `.active::after` 밑줄을 만든다.
 * 활성 상태는 관리자 내비처럼 옅은 면으로 표현하므로 공통 내비 안에서는 제거한다.
 */
.site-header .nav-links a.active::after,
.site-header .nav-links > .nav-cluster.active::after {
  content: none;
}

.site-header .nav-arena-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--matths-ink);
  font-weight: 780;
}

.site-header .nav-arena-link::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--matths-arena-accent);
  border-radius: 50%;
}

.site-header .nav-cluster {
  position: relative;
}

.site-header .nav-cluster summary {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  list-style: none;
}

.site-header .nav-cluster summary::-webkit-details-marker {
  display: none;
}

/*
 * 펼침 표시는 유니코드 글리프 대신 CSS 도형으로 그린다.
 * 글리프는 폰트마다 baseline·자간이 달라 세로 정렬이 흔들리고,
 * 스크린리더가 읽어버릴 수 있어 장식 아이콘으로는 부적합하다.
 * 45도 회전한 사각형으로 그리면 회전한 모서리가 상자 밖으로 나가
 * summary 의 scrollWidth 가 3px 늘어난다. clip-path 는 상자를 그대로 두고,
 * 펼침 상태의 scaleY(-1) 도 경계 상자를 바꾸지 않는다.
 */
.site-header .nav-cluster summary::after {
  content: "";
  width: 14px;
  height: 6px;
  flex: 0 0 14px;
  background: currentColor;
  -webkit-clip-path: polygon(2px 0, 7px 3.6px, 12px 0, 12px 2.4px, 7px 6px, 2px 2.4px);
  clip-path: polygon(2px 0, 7px 3.6px, 12px 0, 12px 2.4px, 7px 6px, 2px 2.4px);
  transition: transform var(--motion-fast) var(--motion-ease);
}

.site-header .nav-cluster[open] summary::after {
  transform: scaleY(-1);
}

.site-header .nav-cluster-menu {
  position: absolute;
  top: calc(100% + 14px);
  left: 50%;
  width: 198px;
  display: grid;
  gap: 5px;
  padding: 10px;
  background: var(--matths-surface);
  border: 1px solid var(--matths-line);
  border-radius: 18px;
  box-shadow: 0 14px 32px rgba(17, 20, 38, 0.1);
  transform: translateX(-50%);
}

.site-header .nav-cluster-menu a {
  min-height: 42px;
  padding: 10px 13px;
  border-radius: 12px;
  transition:
    color var(--motion-fast, 120ms) var(--motion-ease, ease),
    background-color var(--motion-fast, 120ms) var(--motion-ease, ease);
}

.site-header .nav-cluster-menu a:hover,
.site-header .nav-cluster-menu a.active {
  color: var(--matths-violet-text, #6240cf);
  background: var(--matths-primary-soft, #edf1ff);
}

.site-header .nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.site-header .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 720;
  line-height: 1;
  text-decoration: none;
}

.site-header .button-small {
  min-height: 44px;
  padding: 0 18px;
  font-size: 13px;
}

.site-header .button-primary {
  color: #fff;
  background: var(--matths-action-primary, #7b4efc);
  box-shadow: none;
}

.site-header .button-primary:hover {
  background: var(--matths-action-primary-hover, #6339dc);
}

.site-header .mobile-menu {
  display: none;
  position: relative;
}

.site-header .mobile-menu summary {
  width: 44px;
  height: 44px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 9px;
  background: var(--matths-surface);
  border: 1px solid var(--matths-line);
  border-radius: 10px;
  cursor: pointer;
  list-style: none;
}

.site-header .mobile-menu summary::-webkit-details-marker {
  display: none;
}

.site-header .mobile-menu summary span {
  height: 2px;
  background: var(--matths-ink);
}

.site-header .mobile-menu > div {
  position: absolute;
  top: 50px;
  right: 0;
  width: min(320px, calc(100vw - 28px));
  max-height: calc(100vh - 86px);
  display: grid;
  overflow-y: auto;
  padding: 10px;
  background: var(--matths-surface);
  border: 1px solid var(--matths-line);
  border-radius: var(--matths-radius-md);
  box-shadow: 0 16px 38px rgba(17, 20, 38, 0.12);
}

.site-header .mobile-menu > div p {
  margin: 10px 13px 3px;
  color: var(--matths-muted);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: -0.1px;
}

.site-header .mobile-menu > div .mobile-arena-link {
  margin-bottom: 3px;
  color: var(--matths-ink);
  background: #eafcff;
  font-weight: 780;
}

.site-header .mobile-menu > div a {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 12px 13px;
  color: var(--matths-muted);
  border-radius: 9px;
  font-size: 14px;
  font-weight: 680;
  text-decoration: none;
}

/* Public chrome keeps footer and skip-link targets usable on touch screens. */
.skip-link {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.site-header .mobile-menu > div a:hover,
.site-header .mobile-menu > div a.active {
  color: var(--matths-action-primary);
  background: var(--matths-primary-soft);
}

.site-header .mobile-menu > div .mobile-primary-action {
  justify-content: center;
  margin-top: 6px;
  color: var(--matths-on-brand);
  background: var(--matths-action-primary);
  font-weight: 760;
}

.site-header .mobile-menu > div .mobile-primary-action:hover {
  color: var(--matths-on-brand);
  background: var(--matths-action-primary-pressed);
}

/*
 * 푸터 링크의 44px 은 터치 타깃 하한이지 정렬 지시가 아니다.
 * 여기 있던 `justify-content: center` 가 링크 글자를 칸 가운데로 밀어,
 * 세로로 쌓인 푸터(예: intro 의 .footer-links)에서 제목(strong)만 왼쪽에 남고
 * 링크는 가운데로 어긋났다. 그래서 intro.css 가 되돌리는 규칙을 따로 달아야 했다.
 * 하한만 남기면 글자는 각 칸의 시작선에 그대로 붙는다.
 */
.site-footer a {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

@media (max-width: 1040px) {
  .site-header .nav-links {
    gap: 16px;
  }
}

@media (max-width: 1100px) {
  html.public-menu-open {
    overflow: hidden;
  }

  .site-header {
    height: 68px;
  }

  .site-header .nav-links {
    display: none;
  }

  .site-header .mobile-menu {
    display: block;
  }

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

@media (max-width: 560px) {
  .site-header .container {
    width: min(100% - 28px, 1180px);
  }

  .site-header .nav-actions .button {
    display: none;
  }

  .site-header .login-link {
    display: none;
  }
}

@media (max-width: 640px) {
  .site-footer .footer-inner {
    grid-template-columns: 1fr;
    gap: 16px;
    padding-block: 20px;
  }

  .site-footer .footer-brand {
    width: 132px;
    min-width: 120px;
    justify-self: start;
    overflow: visible;
  }

  .site-footer .footer-inner > div {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  /*
   * 페이지 CSS(index/faq/curriculum/visual-learning/learning-flow)가 좁은 폭에서
   * `.footer-inner > div a:first-child { display: none }` 으로 첫 링크를 지운다.
   * 그 첫 링크가 이용약관이라, 모바일에서만 약관이 사라진다.
   * 위 규칙이 이미 한 칸으로 접고 줄바꿈을 허용하므로 자리는 남는다.
   * 약관은 폭과 무관하게 닿을 수 있어야 해서 특이도를 올려 되살린다.
   */
  .site-footer .footer-inner > div a:first-child {
    display: inline-flex;
  }
}
