/* Mobile-first responsive optimizations */

@media (max-width: 768px) {
  body { font-size: 15px; }
  :root { --header-h: 72px; }

  .container { padding: 0 16px; }

  .home-cta { padding: 64px 0; }
  .cta-actions { width: 100%; flex-direction: column; gap: 10px; }
  .cta-actions .btn-hero { width: 100%; text-align: center; }

  .topbar { display: none; }
  .site-header .container { padding: 0 16px; }
  .logo img { height: 40px; }
  .primary-nav {
    position: fixed; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; gap: 0;
    background: #fff;
    border-bottom: 1px solid var(--c-line);
    padding: 8px 0;
    transform: translateY(calc(-110% - var(--header-h)));
    transition: transform .25s ease, visibility 0s linear .25s;
    box-shadow: var(--shadow-md);
    visibility: hidden;
  }
  .primary-nav.open { transform: translateY(0); visibility: visible; transition: transform .25s ease, visibility 0s linear 0s; }
  .primary-nav.open { transform: translateY(0); max-height: calc(100vh - var(--header-h)); overflow-y: auto; }
  .primary-nav > .nav-home,
  .primary-nav .nav-top { padding: 14px 20px; border-bottom: 1px solid var(--c-line-2); font-size: 16px; }

  /* Dropdowns become tap-accordions on mobile */
  .nav-item { position: static; width: 100%; }
  .nav-top { justify-content: space-between; }
  .nav-top .caret { opacity: .8; }
  .nav-sub {
    position: static; transform: none; display: none;
    min-width: 0; border: 0; border-radius: 0; box-shadow: none;
    padding: 0; background: var(--c-line-2);
  }
  .nav-item.open .nav-sub { display: block; }
  .nav-item.open .nav-top .caret { transform: rotate(180deg); }
  .nav-sub a { padding: 13px 32px; border-bottom: 1px solid var(--c-line); font-size: 15px; }
  .nav-sub a:last-child { border-bottom: 0; }
  .nav-toggle { display: flex; }

  .nav-member-m { display: flex; flex-direction: row; border-top: 2px solid var(--c-line); }
  .nav-member-m a { flex: 1; text-align: center; padding: 15px 12px; font-size: 16px; font-weight: 600; color: var(--c-primary); }
  .nav-member-m a + a { border-left: 1px solid var(--c-line); }

  /* 헤더의 언어 드롭다운은 숨기고 햄버거 메뉴 안으로 */
  .header-actions .lang-switcher { display: none; }
  .nav-lang-m { display: block; padding: 14px 20px 16px; border-top: 1px solid var(--c-line-2); }
  .nav-lang-m .nlm-label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .1em; color: var(--c-muted); margin-bottom: 8px; text-transform: uppercase; }
  .nav-lang-m .nlm-opts { display: flex; gap: 8px; flex-wrap: wrap; }
  .nav-lang-m .nlm-opts a { padding: 8px 14px; border: 1px solid var(--c-line); border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--c-fg); }
  .nav-lang-m .nlm-opts a.on { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

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

  .page-hero { padding: 60px 0 48px; margin-bottom: 22px; }
  .page-hero h1 { font-size: 23px; }
  .page-hero .hero-crumbs { font-size: 13px; }

  .two-col { grid-template-columns: 1fr; gap: 16px; padding: 32px 16px; }
  .card-head h2 { font-size: 22px; }
  .post-list a { font-size: 14px; }
  .post-list time { font-size: 12px; }
  .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;
  }
}
