/* ============================================================
   동사연 — 공통 레이아웃 CSS (Phase 0 모듈화)
   common.css — 전 페이지 공유: 리셋 · 탑바 · GNB · 브레드크럼 ·
   플로팅 버튼 · 푸터. 디자인 토큰은 colors_and_type.css 참조.
   페이지별 변형(예: footer.site margin-top)은 각 페이지 <style>에서
   이 파일 로드 이후에 오버라이드한다.
   ============================================================ */

/* ============ Base ============ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); }

/* ============ Top Utility Bar ============ */
.topbar { background: var(--brand-900); color: var(--paper-300); font-size: 14px; padding: 7px 0; letter-spacing: -0.01em; }
.topbar .wrap { max-width: 1280px; margin: 0 auto; padding: 0 32px; display: flex; justify-content: space-between; align-items: center; }
.topbar a { color: var(--paper-300); text-decoration: none; margin-left: 18px; transition: color 0.15s; }
.topbar a:hover { color: var(--paper); }
.topbar .left { display:flex; align-items: center; gap: 14px; }
.topbar .left .slogan { color: var(--accent-300); font-weight: 600; }

/* ============ Header / Main GNB ============ */
header.gnb { background: var(--white); border-bottom: 1px solid var(--border-1); box-shadow: 0 1px 0 rgba(0,0,0,0.02), 0 4px 16px rgba(10, 36, 64, 0.04); position: sticky; top: 0; z-index: 100; }
.gnb-wrap { max-width: 1280px; margin: 0 auto; padding: 0 32px; display:flex; align-items: center; justify-content: space-between; gap: 24px; }
.logo { display: flex; align-items: center; gap: 12px; text-decoration: none; transition: opacity 0.2s; padding: 4px 6px; border-radius: 10px; }
.logo:hover { opacity: 0.88; }
.logo .symbol { height: 62px; width: auto; object-fit: contain; flex-shrink: 0; }
nav.main { display: flex; align-items: center; padding: 4px; }
.nav-item { position: relative; }
.nav-item > a { display: inline-flex; align-items: center; padding: 10px 18px; color: var(--paper-600); text-decoration: none; font-size: 18px; font-weight: 600; letter-spacing: -0.015em; transition: all 0.18s var(--ease-out); position: relative; }
.nav-item:hover > a { color: var(--brand-700); }
.nav-item.active > a { color: var(--brand-700); }
.gnb-cta { display: flex; gap: 8px; align-items: center; }
.gnb-cta-divider { width: 1px; height: 24px; background: var(--paper-200); margin: 0 4px; }

/* ============ Buttons ============ */
.btn { font-family: inherit; font-size: 14px; font-weight: 700; padding: 10px 18px; border-radius: 10px; cursor: pointer; border: 1px solid transparent; transition: all 0.2s var(--ease-out); letter-spacing: -0.015em; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn.donate { background: linear-gradient(135deg, var(--accent-500) 0%, var(--accent-600) 100%); color: var(--paper); box-shadow: 0 2px 6px rgba(212, 78, 44, 0.32), inset 0 1px 0 rgba(255,255,255,0.18); position: relative; overflow: hidden; }
.btn.donate svg { animation: heart-pulse 1.6s ease-in-out infinite; }
@keyframes heart-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.btn.donate:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(212, 78, 44, 0.42), inset 0 1px 0 rgba(255,255,255,0.22); }
.btn.outline { background: var(--white); color: var(--brand-700); border-color: var(--paper-200); }
.btn.outline:hover { background: var(--brand-50); border-color: var(--brand-400); color: var(--brand-800); }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; background: var(--paper-warm); border: 1px solid transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--fg-2); transition: all 0.2s; }
.icon-btn:hover { background: var(--white); border-color: var(--brand-200); color: var(--brand-700); box-shadow: 0 2px 6px rgba(10, 36, 64, 0.06); }
.icon-btn svg { width: 18px; height: 18px; }

/* ============ Breadcrumb bar ============ */
.crumb-bar { background: var(--white); border-bottom: 1px solid var(--border-1); padding: 10px 0; }
.crumb-bar .wrap { max-width: 1280px; margin: 0 auto; padding: 0 32px; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--fg-3); margin: 0; }
.breadcrumb a { color: var(--fg-3); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; transition: color 0.15s; }
.breadcrumb a:hover { color: var(--brand-600); }
.breadcrumb svg { width: 12px; height: 12px; }
.breadcrumb .sep { color: var(--paper-300); }
.breadcrumb .current { color: var(--brand-700); font-weight: 700; }

/* ============ Floating buttons ============ */
.float-donate { position: fixed; right: 28px; bottom: 28px; background: var(--accent-500); color: var(--paper); border: none; padding: 13px 22px; border-radius: 999px; font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer; box-shadow: 0 12px 28px rgba(212,78,44,0.4); display: flex; align-items: center; gap: 8px; transition: all 0.2s var(--ease-out); z-index: 50; }
.float-donate:hover { background: var(--accent-600); transform: translateY(-2px); }
.float-donate svg { width: 16px; height: 16px; }
.back-top { position: fixed; right: 28px; bottom: 86px; width: 44px; height: 44px; background: var(--white); border: 1px solid var(--border-2); border-radius: 50%; cursor: pointer; box-shadow: var(--shadow-md); display: flex; align-items: center; justify-content: center; color: var(--ink); transition: all 0.2s; z-index: 50; }
.back-top svg { width: 18px; height: 18px; }

/* ============ Footer ============ */
footer.site { background: var(--brand-950); color: var(--paper-300); padding: 48px 0 0; }
.footer-wrap { max-width: 1280px; margin: 0 auto; padding: 0 32px; }
.footer-top-logo { display: flex; align-items: center; gap: 14px; padding-bottom: 24px; }
.footer-top-logo img { background: rgba(255,255,255,0.95); padding: 4px 8px; border-radius: 8px; height: 44px; }
.footer-top-logo .name { font-family: var(--font-display); font-size: 22px; font-weight: 800; color: var(--paper); letter-spacing: -0.03em; }
.footer-top-logo .sub { font-size: 12px; color: var(--paper-300); margin-top: 2px; }
.footer-info { padding: 22px 0; font-size: 12px; color: var(--paper-400); font-family: var(--font-mono); line-height: 1.7; display: flex; justify-content: space-between; gap: 28px; border-top: 1px solid rgba(255,255,255,0.08); }
.footer-info b { color: var(--paper-200); font-family: var(--font-sans); font-weight: 600; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,0.08); padding: 18px 0 22px; font-size: 11px; color: var(--paper-400); display: flex; justify-content: space-between; }

/* ============ Mobile nav (햄버거 + 드로어 — ui.js가 마크업 생성) ============ */
.gnb-burger { display: none; width: 42px; height: 42px; border: none; background: transparent; border-radius: 10px; cursor: pointer; color: var(--brand-900); align-items: center; justify-content: center; flex-shrink: 0; }
.gnb-burger svg { width: 24px; height: 24px; }
.gnb-burger:hover { background: var(--paper-warm); }
.mnav-overlay { position: fixed; inset: 0; background: rgba(10, 20, 32, 0.45); opacity: 0; pointer-events: none; transition: opacity 0.25s; z-index: 200; }
.mnav-overlay.open { opacity: 1; pointer-events: auto; }
.mnav-drawer { position: fixed; top: 0; right: 0; height: 100vh; height: 100dvh; width: min(320px, 86vw); background: var(--white); box-shadow: -8px 0 32px rgba(0,0,0,0.18); transform: translateX(105%); transition: transform 0.28s var(--ease-out, ease-out); z-index: 201; display: flex; flex-direction: column; }
.mnav-drawer.open { transform: none; }
.mnav-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 14px 22px; border-bottom: 1px solid var(--border-1); }
.mnav-title { font-family: var(--font-display); font-size: 16px; font-weight: 800; color: var(--brand-900); }
.mnav-close { width: 40px; height: 40px; border: none; background: transparent; border-radius: 10px; cursor: pointer; color: var(--fg-2); display: flex; align-items: center; justify-content: center; }
.mnav-close svg { width: 22px; height: 22px; }
.mnav-close:hover { background: var(--paper-warm); }
.mnav-links { display: flex; flex-direction: column; padding: 8px 0; overflow-y: auto; }
.mnav-links a { padding: 15px 22px; color: var(--paper-600); text-decoration: none; font-size: 16.5px; font-weight: 600; letter-spacing: -0.015em; border-bottom: 1px solid var(--border-1); }
.mnav-links a.active { color: var(--brand-700); font-weight: 800; box-shadow: inset 3px 0 0 var(--accent-500); background: var(--brand-50); }
.mnav-cta { padding: 18px 22px; margin-top: auto; }
.mnav-cta .btn.donate { width: 100%; justify-content: center; padding: 13px 18px; font-size: 15px; }
.mnav-util { display: flex; gap: 18px; padding: 0 22px 22px; }
.mnav-util a { color: var(--fg-3); text-decoration: none; font-size: 13px; }
body.mnav-lock { overflow: hidden; }

/* ============ Responsive: 페이지 공용 패턴 (Phase 2) ============
   .layout/.sidebar/.ph-wrap/.control-bar/게시판 테이블 등은 여러 페이지의
   인라인 <style>에 정의된 공용 패턴. common.css가 인라인보다 먼저 로드되므로
   여기의 반응형 오버라이드는 body 접두로 특이도를 높여 인라인 기본값을 이긴다. */
@media (max-width: 1024px) {
  body .layout { grid-template-columns: 1fr; padding: 24px 20px; gap: 22px; }
  body .sidebar { position: static; max-height: none; overflow: visible; }
  /* .sb-split 레이아웃(리스트 페이지): 사이드바를 분해해 내비 섹션은 본문 위,
     CTA 섹션(.sb-cta — 알림받기·후원 등)은 본문 아래(제일 밑)로 배치 */
  body .layout.sb-split > .sidebar { display: contents; }
  /* .side-group: policy처럼 탭 전환용 래퍼로 감싼 섹션도 동일하게 내비 그룹(order 1)에 포함 */
  body .layout.sb-split > .sidebar > .sidebar-section,
  body .layout.sb-split > .sidebar > .side-group { order: 1; margin-bottom: 0; }
  body .layout.sb-split > .content { order: 2; }
  body .layout.sb-split > .sidebar > .sidebar-section.sb-cta { order: 3; }
  body .side-nav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  body .side-nav a { flex: 0 1 auto; padding: 8px 12px; border: 1px solid var(--border-1); border-radius: 999px; }
  body .side-nav a.active { padding-left: 12px; }
  body .side-nav a.active::before { display: none; }
  body .side-nav a .ct { min-width: auto; }
}
@media (max-width: 768px) {
  body .ph-wrap { flex-direction: column; align-items: flex-start; gap: 14px; }
  body .ph-title h1 { font-size: 27px; gap: 10px; }
  body .ph-title .ic { width: 38px; height: 38px; }
  body .ph-title .ic svg { width: 20px; height: 20px; }
  body .ph-title p { margin-left: 0; font-size: 13.5px; }
  body .ph-stats { gap: 18px; }
  body .ph-stat { align-items: flex-start; }
  body .control-bar { flex-wrap: wrap; gap: 12px; }
  body .cb-search input { width: 120px; }
  body .pagination { flex-wrap: wrap; }
  body .boards { grid-template-columns: 1fr; gap: 16px; }
  /* 게시판 테이블 → 카드형 (notice-table · archive-board 공용) */
  body .notice-table thead, body .archive-board thead { display: none; }
  body .notice-table, body .notice-table tbody, body .notice-table tr,
  body .archive-board, body .archive-board tbody, body .archive-board tr { display: block; width: 100%; }
  body .notice-table tr, body .archive-board tr { padding: 14px 14px; border-bottom: 1px solid var(--border-1); }
  /* 배경색 있는 고정 공지 행은 카드처럼 보이도록 모서리 라운드 */
  body .notice-table tr.pinned, body .archive-board tr.pinned { border-radius: 10px; }
  body .notice-table td, body .archive-board td { display: none; }
  body .notice-table td.cat, body .archive-board td.cat { display: inline-block; width: auto; padding: 0 0 6px; text-align: left; }
  body .notice-table td.title-cell, body .archive-board td.title-cell { display: block; width: auto; padding: 0 0 6px; text-align: left; }
  body .notice-table td.author, body .notice-table td.date,
  body .archive-board td.author, body .archive-board td.date { display: inline-block; width: auto; padding: 0 12px 0 0; font-size: 12px; text-align: left; }
  /* 서브내비 바 (about/history/charter/support 공용) — 모바일 가로 스크롤 */
  body .subnav-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  body .subnav-wrap a { padding: 13px 16px; font-size: 13.5px; white-space: nowrap; }
  /* iOS Safari: 16px 미만 입력창은 포커스 시 화면이 강제 확대됨 → 모바일에서만 16px 보장.
     인라인 페이지 CSS(12.5~14px)를 확실히 이기기 위한 의도적 !important */
  body input, body select, body textarea { font-size: 16px !important; }
  /* iPhone 홈 인디케이터(safe-area)와 플로팅 버튼 겹침 방지 */
  .float-donate { bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  .back-top { bottom: calc(68px + env(safe-area-inset-bottom, 0px)); }
  .mnav-drawer { padding-bottom: env(safe-area-inset-bottom, 0px); }
  /* 터치 타겟 확장: '더보기'류 텍스트 링크 — 패딩+역마진으로 레이아웃 변화 없이 히트 영역만 확대 */
  body a.more, body a.more-link, body a.back-link, body a.request-link { padding: 10px 8px; margin: -10px -8px; }
  body .breadcrumb a { padding: 8px 4px; margin: -8px -4px; }
  /* 페이지 래퍼 좌우 여백 통일: 데스크톱 32px → 모바일 20px */
  body .ph-wrap, body .hero-wrap, body .subnav-wrap, body .ct-wrap,
  body .cta-wrap, body .closing-wrap, body .sw, body .topic-wrap,
  body .indep-grid, body .philo-content,
  body .era-wrap, body .mem-wrap, body .donate-cta-wrap { padding-left: 20px; padding-right: 20px; }
}

/* ============ Responsive: Tablet (≤1024px) ============ */
@media (max-width: 1024px) {
  nav.main { display: none; }
  .gnb-cta .icon-btn, .gnb-cta .btn.outline, .gnb-cta-divider { display: none; }
  .gnb-burger { display: flex; }
  /* 메뉴가 숨으면 space-between 탓에 후원 버튼이 중앙에 뜸 → 로고 좌측, [후원+햄버거] 우측 고정 */
  .gnb-wrap { padding: 0 20px; gap: 12px; justify-content: flex-end; }
  .gnb-wrap .logo { margin-right: auto; }
  .logo .symbol { height: 52px; }
  .topbar .wrap { padding: 0 20px; }
  .topbar .left span:not(.slogan) { display: none; }
}

/* ============ Responsive: Mobile (≤768px) ============ */
@media (max-width: 768px) {
  .topbar { display: none; }
  .gnb-wrap { padding: 0 14px; }
  .logo .symbol { height: 44px; }
  .gnb-cta .btn.donate { padding: 8px 13px; font-size: 13px; }
  .crumb-bar .wrap { padding: 0 20px; }
  .breadcrumb .current { max-width: 55vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  footer.site { padding: 36px 0 0; }
  .footer-wrap { padding: 0 20px; }
  .footer-info { flex-direction: column; gap: 10px; }
  .footer-bottom { flex-direction: column; gap: 6px; }
  .float-donate { right: 16px; bottom: 16px; padding: 12px 18px; font-size: 12.5px; }
  .back-top { right: 16px; bottom: 68px; width: 40px; height: 40px; }
}
