/* Mobile-first responsive optimizations */

@media (max-width: 768px) {
  body { font-size: 16px; }

  .container { padding: 0 16px; }

  .site-header .container { padding: 0 16px; }
  .primary-nav {
    position: fixed; top: 0; left: 0; right: 0;
    flex-direction: column; gap: 0;
    background: #fff;
    border-bottom: 1px solid var(--c-line);
    padding: 8px 0;
    /* 닫힘: top:0 기준 자기 높이만큼 위로 → 헤더 높이와 무관하게 완전히 숨김 */
    transform: translateY(-100%);
    transition: transform .25s ease;
    box-shadow: var(--shadow-md);
    z-index: 40;
  }
  /* 열림: 헤더 아래로 내려옴 */
  .primary-nav.open { transform: translateY(var(--header-h)); }
  .primary-nav a { padding: 14px 20px; border-bottom: 1px solid var(--c-line-2); font-size: 16px; }
  .primary-nav a:last-child { border-bottom: 0; }
  .nav-toggle { display: flex; }

  .hero { padding: 56px 0 40px; }
  .hero-title { font-size: 34px; }
  .hero-subtitle { font-size: 16px; }

  .two-col { grid-template-columns: 1fr; gap: 16px; padding: 32px 16px; }
  .feature-grid { grid-template-columns: repeat(3, 1fr); padding: 32px 16px 56px; gap: 10px; }
  .feature-tile { padding: 18px 8px; }
  .ft-icon { font-size: 22px; }
  .ft-title { font-size: 12px; }

  .board-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .board-title { font-size: 22px; }
  .board-tools { flex-direction: column; align-items: stretch; }
  .search { width: 100%; }
  .search input { flex: 1; }

  /* 게시판 목록 — 좁은 화면에서는 표를 카드 목록으로 바꾼다.
     5칸을 유지하면 제목 칸이 80px 까지 줄어 제목이 네댓 줄로 쪼개진다.
     제목을 한 줄 통째로 쓰고, 번호·작성자·작성일·조회는 아래 한 줄 메타로 모은다. */
  .board-table thead { display: none; }
  .board-table, .board-table tbody { display: block; width: 100%; }
  .board-table tr {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px;
    padding: 15px 2px 14px; border-bottom: 1px solid var(--c-line);
  }
  /* main.css 의 .board-table td:nth-last-child(-n+3) 좌우 16px 여백을 같은 무게로 지운다 */
  .board-table td,
  .board-table td:nth-last-child(-n+3) {
    display: block; border: 0; padding: 0;
    font-size: 12.5px; color: var(--c-muted); white-space: nowrap;
  }
  .board-table td.subj {
    flex: 0 0 100%; order: -1; margin-bottom: 7px;
    font-size: 15px; line-height: 1.5; color: var(--c-fg); white-space: normal;
  }
  .board-table td.subj a { font-weight: 600; }
  .board-table td:not(.subj) ~ td:not(.subj)::before {
    content: '·'; margin-right: 7px; color: #c6ccd6;
  }
  .board-table td.empty { flex: 0 0 100%; padding: 36px 0; font-size: 14px; text-align: center; }
  .board-table .adm-col, .board-table td:has(> input[type="checkbox"]) { display: none; }

  .photo-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  .calendar td { min-height: 70px; height: 70px; padding: 4px; }
  .calendar td .d { font-size: 12px; }
  .cal-event { font-size: 10px; padding: 1px 4px; }

  .post-view { padding: 24px 16px 60px; }
  .post-head h1 { font-size: 22px; }
  .post-body { font-size: 16px; padding: 16px 0; }

  .write-form .row { grid-template-columns: 1fr; }

  /* Popup mobile: image auto-resize, centered */
  .popup-stack {
    left: 16px !important; right: 16px !important; top: 50% !important;
    transform: translateY(-50%) !important;
    align-items: center;
  }
  .popup {
    width: calc(100vw - 32px) !important; max-width: 480px;
    margin: 0 auto;
  }
  .popup img { width: 100%; height: auto; }
}

@media (max-width: 480px) {
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
  .calendar { font-size: 11px; }
  .calendar td { min-height: 56px; height: 56px; }
}

/* iOS notch / safe-area */
@supports (padding: env(safe-area-inset-bottom)) {
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* Reduce motion respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
