/* Mobile-first responsive optimizations */

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

  .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; }

  .board-table .meta-col:nth-child(n+5) { display: none; }
  .board-table th, .board-table td { font-size: 13px; padding: 10px 6px; }

  .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: 15px; 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;
  }
}

/* ── 모바일 손질 2026-09-21 ── */
@media (max-width: 768px) {

  /* 1) 상단 국기 줄 — 10개가 두 줄로 접혀 상단을 73px 차지했다. 한 줄로 두고 옆으로 민다. */
  .topbar .container { height:46px; gap:10px; }
  .tb-langs { flex-wrap:nowrap; overflow-x:auto; overflow-y:hidden; gap:2px;
              scrollbar-width:none; -webkit-overflow-scrolling:touch; }
  .tb-langs::-webkit-scrollbar { display:none; }
  .tb-langs a { flex:0 0 auto; min-width:38px; min-height:38px; display:flex;
                align-items:center; justify-content:center; }
  .tb-out { flex:0 0 auto; }
  .tb-out a { min-width:38px; min-height:38px; display:flex; align-items:center; justify-content:center; }

  /* 2) PROJECT 카드 띠 — 카드가 화면 끝에 붙어 잘려 보였다.
        본문과 같은 16px 여백에서 시작하고, 한 장씩 딱 멈추게 한다. */
  .proj-rail { scroll-snap-type:x mandatory; scroll-padding-left:16px; scroll-padding-right:16px; }
  .proj-track { padding-left:16px; padding-right:16px; gap:14px; }
  .proj-card { flex:0 0 min(78vw, 300px); }
  .proj-hint { display:flex; }

  /* 3) 12px 대 글자는 휴대폰에서 읽기 힘들다 — 13px 이상으로 */
  .np-brand, .np-url, .as-lab, .ed-no, .ed-meta, .sw-tag, .nh-badge, .np-meta { font-size:13px; }
  .pf-bar b { font-size:13px; }

  /* 4) 아이콘 뒤 빛번짐이 상자 밖으로 나가 잘렸다 — 상자 안에 들어오게 */
  .as-ico::before { width:96px; height:96px; }

  /* 5) 손가락으로 누르는 곳은 최소 36px */
  .mv-dot { min-width:36px; min-height:36px; }
}
/* ── /모바일 손질 2026-09-21 ── */
