/**
 * 회칙 페이지 (about/rule.php)
 */

/* ── 페이지 ── */
.wrap-content .sub-content.rule-page {
  padding-top: 32px;
  padding-bottom: 120px;
}

@media (max-width: 768px) {
  .wrap-content .sub-content.rule-page {
    padding-top: 30px;
    padding-bottom: 50px;
  }
}

/* 공통 서브타이틀보다 아래 여백 축소 (탭·본문과 간격) */
.wrap-content .sub-content.rule-page .sub-page-subtitle {
  padding: 60px 0 50px;
}

@media (max-width: 768px) {
  .wrap-content .sub-content.rule-page .sub-page-subtitle {
    padding: 30px 0 32px;
  }
}

/* 개정 버전 뱃지 (sub-page-subtitle 안) */
.rule-page .rule-page__version {
  display: inline-block;
  margin-top: 14px;
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  background: #f3f4f6;
  padding: 4px 14px;
  border-radius: 20px;
}

.rule-page .rule-page__version[hidden] {
  display: none !important;
}

/* ── 장별 탭 (앵커 스크롤) ── */
.rule-tabs {
  margin: 0 0 80px;
  padding: 0;
}

.rule-tabs__list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 10px 12px;
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}

.rule-tabs__list:last-child {
  margin-bottom: 0;
}

.rule-tabs__list > li {
  margin: 0;
  padding: 0;
}

.rule-tabs__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 25px;
  max-width: 280px;
  box-sizing: border-box;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.35;
  text-align: center;
  color: #4b457a!important;
  text-decoration: none;
  background: #fff;
  border: 1px solid #4b457a;
  border-radius: 2px;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.rule-tabs__link.is-active {
  background: #4b457a;
  color: #fff!important;
  border-color: #4b457a;
}

.rule-tabs__link.is-disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

@media (max-width: 768px) {
  .rule-tabs {
    margin-bottom: 28px;
  }

  .rule-tabs__link {
    font-size: 13px;
    padding: 8px 12px;
    min-height: 40px;
    max-width: 100%;
  }
}

/* 고정 헤더 보정 */
#bylaws-content,
.rule-content h1,
.rule-content h2,
.rule-content h3 {
  scroll-margin-top: 100px;
}

@media (max-width: 768px) {
  #bylaws-content,
  .rule-content h1,
  .rule-content h2,
  .rule-content h3 {
    scroll-margin-top: 72px;
  }
}

/* ── 로딩 ── */
.rule-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  color: #8a8a8a;
  font-size: 15px;
  gap: 16px;
}

.rule-loader__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: #1e40af;
  border-radius: 50%;
  animation: rule-spin 0.7s linear infinite;
}

@keyframes rule-spin {
  to { transform: rotate(360deg); }
}

/* ── 빈 상태 ── */
.rule-empty {
  text-align: center;
  padding: 40px 0;
  color: #8a8a8a;
  font-size: 15px;
  margin: 0;
}

/* ── DB에서 불러온 회칙 콘텐츠 (HTML) ── */
.rule-content {
  font-size: 15px;
  line-height: 1.85;
  color: #333;
  word-break: keep-all;
}

/* 본문에 section/article로 묶인 경우 섹션 하단 여백 */
.rule-content section,
.rule-content article {
  padding-bottom: 40px;
}

.rule-content section:last-child,
.rule-content article:last-child {
  padding-bottom: 0;
}

.rule-content h1,
.rule-content h2,
.rule-content h3,
.rule-content h4,
.rule-content h5,
.rule-content h6 {
  margin: 2em 0 0.3em;
  font-weight: 500;
  line-height: 1.4;
}

/* 장 제목: 퍼플 + 하단 구분선 + 섹션 하단 패딩 */
.rule-content h1,
.rule-content h2 {
  color: #4b457a;
  font-size: 20px;
  padding-top: 8px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid #e0e0e0;
}

.rule-content h1 { font-size: 26px; }

.rule-content h3,
.rule-content h4 {
  color: #202020;
  font-size: 17px;
  margin-top: 1.85em;
}

.rule-content h5,
.rule-content h6 {
  padding-bottom: 12px;
  margin-top: 1.35em;
  margin-bottom: 0.7em;
}

@media (max-width: 768px) {
  .rule-content section,
  .rule-content article {
    padding-bottom: 28px;
  }

  .rule-content h1,
  .rule-content h2 {
    padding-bottom: 22px;
    margin-bottom: 1.25em;
  }

  .rule-content h3,
  .rule-content h4 {
    padding-bottom: 14px;
    margin-top: 1.5em;
    margin-bottom: 0.85em;
  }

  .rule-content h5,
  .rule-content h6 {
    padding-bottom: 10px;
    margin-top: 1.2em;
    margin-bottom: 0.65em;
  }

  .rule-content h1 { font-size: 20px; }
  .rule-content h2 { font-size: 18px; }
  .rule-content h3 { font-size: 16px; }
}

.rule-content h1:first-child,
.rule-content h2:first-child,
.rule-content h3:first-child {
  margin-top: 0;
}

.rule-content p {
  margin: 0 0 2em;
}

.rule-content ul,
.rule-content ol {
  margin: 0 0 1em;
  padding-left: 1.6em;
}

.rule-content ul { list-style: disc !important; }
.rule-content ol { list-style: decimal !important; }

.rule-content li {
  margin-bottom: 0.4em;
  list-style: inherit !important;
}

.rule-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 14px;
}

.rule-content th,
.rule-content td {
  border: 1px solid #d1d5db;
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
}

.rule-content th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
}

.rule-content strong,
.rule-content b {
  font-weight: 700;
}

.rule-content a {
  color: #1e40af;
  text-decoration: underline;
}

.rule-content a:hover {
  opacity: 0.8;
}

.rule-content blockquote {
  margin: 1.2em 0;
  padding: 16px 20px;
  border-left: 4px solid #1e40af;
  background: #f8fafc;
  color: #374151;
  font-style: italic;
}

.rule-content hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 2em 0;
}

/* ── 맨 위로 (스크롤 시 우하단) ── */
.rule-backtotop {
  position: fixed;
  right: max(20px, env(safe-area-inset-right, 0px));
  bottom: max(24px, env(safe-area-inset-bottom, 0px));
  z-index: 95;
  width: 50px;
  height: 50px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #4b457a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0.28s ease, transform 0.28s ease, background 0.2s ease;
  transform: translateY(10px);
}

.rule-backtotop--visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.rule-backtotop:hover {
  background: #3f3968;
}

.rule-backtotop:focus-visible {
  outline: 2px solid #4b457a;
  outline-offset: 3px;
}

.rule-backtotop img {
  display: block;
  object-fit: contain;
}

@media (max-width: 768px) {
  .rule-backtotop {
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: max(20px, env(safe-area-inset-bottom, 0px));
    width: 40px;
    height: 40px;
  }

}
