/* ==========================================================
   한국뇌심리연구소 모바일 반응형 보정
   main.css 뒤에 추가로 불러오세요 (기존 파일은 수정하지 않습니다)
   대상: 안드로이드 크롬 / 화면 폭 820px 이하
   목적: 글꼴 확대 설정을 쓰는 시니어 사용자도 내용이 잘리지 않게 함
   ========================================================== */

/* ---------- 1. 모든 화면 공통 ---------- */
html {
  /* 시니어의 글꼴 확대 설정을 막지 않는다. 대신 레이아웃이 견디도록 아래에서 처리 */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (max-width: 820px) {

  /* ---------- 2. 화면보다 넓어지는 요소 차단 ---------- */
  .dir-photo-wrap,
  .dir-photo,
  .dir-name,
  .dir-role,
  .tag-row,
  .mini-timeline,
  .sec-head,
  .hero-highlight,
  .sys-card,
  .senior-card {
    width: auto !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  img, svg, video, iframe, canvas, table {
    max-width: 100% !important;
    height: auto;
  }

  /* 플렉스/그리드 자식이 줄어들 수 있게 (넘침의 가장 흔한 원인) */
  .wrap > *,
  .sec-head > *,
  .dir-card > *,
  .sys-card > *,
  [class*="grid"] > *,
  [class*="row"] > * {
    min-width: 0 !important;
  }

  /* ---------- 3. 줄바꿈 허용 (잘림 방지의 핵심) ---------- */
  .dir-name,
  .dir-role,
  .sec-title,
  .sec-desc,
  .brand-text b,
  .brand-text small,
  .org-senior-tags span,
  .sys-badge,
  .senior-badge,
  .navlinks a,
  .mt-year,
  .mt-desc,
  .btn,
  .hero-title,
  .hero-sub,
  h1, h2, h3, h4, p, span, li, td, a {
    white-space: normal !important;
    word-break: keep-all;
    overflow-wrap: break-word;
  }

  /* ---------- 4. 글자 크기: 확대해도 넘치지 않도록 유동값 ---------- */
  .sec-title    { font-size: clamp(19px, 5.6vw, 30px) !important; line-height: 1.4 !important; }
  .hero-title   { font-size: clamp(20px, 6.2vw, 34px) !important; line-height: 1.35 !important; }
  .sec-desc     { font-size: clamp(14px, 4vw, 17px)   !important; line-height: 1.8 !important; }
  .dir-name     { font-size: clamp(16px, 4.8vw, 22px) !important; }
  .dir-role     { font-size: clamp(13px, 3.6vw, 16px) !important; line-height: 1.7 !important; }
  .brand-text b { font-size: clamp(15px, 4.6vw, 22px) !important; line-height: 1.2 !important; }
  .brand-text small { font-size: clamp(9px, 2.6vw, 12px) !important; }

  /* ---------- 5. 헤더가 겹치지 않도록 ---------- */
  header .wrap {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
  }
  .brand-text {
    min-width: 0 !important;
    flex: 1 1 auto !important;
    overflow: hidden;
  }
  .navactions {
    flex: 0 0 auto !important;
    gap: 8px !important;
  }
  .dotmark { flex: 0 0 auto !important; }

  /* ---------- 6. 가로로 긴 목록은 스크롤로 (잘리지 않게) ---------- */
  .mini-timeline {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px !important;
  }
  .mt-item { flex: 0 0 auto !important; }

  /* 태그 줄은 줄바꿈 */
  .tag-row,
  .org-senior-tags {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* ---------- 7. 시니어 가독성 (연구소 주 대상층) ---------- */
  body { line-height: 1.75; }
  .sec-desc, p { letter-spacing: -0.01em; }

  /* 터치 영역 최소 44px 확보 */
  .btn, .navlinks a, .iconbtn, .navtoggle {
    min-height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* ---------- 8. 좌우 여백 통일 ---------- */
  .wrap { padding-left: 16px !important; padding-right: 16px !important; }
}

/* ---------- 9. 소형 단말 ---------- */
@media (max-width: 380px) {
  .wrap { padding-left: 14px !important; padding-right: 14px !important; }
  .brand-text small { display: none !important; }
}

/* ==========================================================
   10. 헤더 모바일 최적화 (2026-08-30 재작성)

   [이전 실패 원인]
   .dotmark 바깥 상자만 줄이고, 안의 4색 점(.d1~.d4)이
   고정 px로 절대배치된 것을 그대로 두어 점들이 상자 밖으로
   삐져나와 햄버거 버튼을 덮고 상호명을 밀어냈음.

   [해결]
   4색 점의 크기와 좌표를 원본 비율(70x63 기준) 그대로
   50%로 축소하여 하나씩 다시 지정.
   ========================================================== */
@media (max-width: 820px) {

  :root { --header-h: 72px; }
  header { height: 72px !important; }

  header .wrap.nav {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
    flex-wrap: nowrap !important;
    padding-left: 14px !important;
    padding-right: 14px !important;
  }

  /* ----- 로고: 컨테이너와 점 4개를 함께 50% 축소 ----- */
  .brand { gap: 9px !important; min-width: 0 !important; flex: 1 1 auto !important; }
  .dotmark {
    width: 35px !important;
    height: 32px !important;
    flex: 0 0 35px !important;
  }
  .dotmark::before { inset: -5px !important; filter: blur(2px) !important; }
  .dotmark .d1 { width: 15px !important;  height: 15px !important;  left: 0 !important;    top: 8px !important; }
  .dotmark .d2 { width: 9px  !important;  height: 9px  !important;  left: 14.5px !important; top: 0 !important; }
  .dotmark .d3 { width: 8px  !important;  height: 8px  !important;  left: 24px !important;  top: 14.5px !important; }
  .dotmark .d4 { width: 6px  !important;  height: 6px  !important;  left: 5.5px !important; top: 22.5px !important; }

  /* ----- 상호명: 반드시 보이게 ----- */
  .brand-text {
    display: flex !important;
    flex-direction: column !important;
    min-width: 0 !important;
    overflow: visible !important;
    line-height: 1.15 !important;
  }
  .brand-text b {
    font-size: clamp(15px, 4.4vw, 20px) !important;
    line-height: 1.15 !important;
    white-space: nowrap !important;
    /* 그라디언트 글자 애니메이션이 투명 처리되는 문제 차단 */
    background: none !important;
    -webkit-text-fill-color: var(--navy) !important;
    color: var(--navy) !important;
    animation: none !important;
  }
  .brand-text small {
    font-size: clamp(7px, 2.1vw, 9.5px) !important;
    letter-spacing: .01em !important;
    white-space: nowrap !important;
  }

  /* ----- 우측 버튼: 터치 44px 확보 ----- */
  .navactions { gap: 6px !important; flex: 0 0 auto !important; }
  .iconbtn {
    width: 42px !important; height: 42px !important;
    min-height: 42px !important; box-shadow: none !important;
  }
  .iconbtn svg { width: 19px !important; height: 19px !important; }
  .navtoggle {
    width: 42px !important; height: 42px !important;
    min-height: 42px !important; font-size: 19px !important;
    padding: 0 !important; border-radius: 10px !important;
  }
  .navlinks { top: 72px !important; }
}

/* ----- 좁은 폰(≤400px) ----- */
@media (max-width: 400px) {
  .brand { gap: 7px !important; }
  .brand-text b { font-size: clamp(13px, 4.1vw, 17px) !important; }
  .brand-text small { display: none !important; }
  .navactions { gap: 4px !important; }
  .iconbtn, .navtoggle { width: 38px !important; height: 38px !important; min-height: 38px !important; }
  .iconbtn svg { width: 17px !important; height: 17px !important; }
  .navtoggle { font-size: 17px !important; }
}

/* 11. 가로 넘침 최종 차단 */
html, body { overflow-x: hidden !important; max-width: 100% !important; }

/* 12. 히어로 하단 CTA 바 — 좁은 화면 여백 보정 */
@media (max-width: 420px) {
  .hero-cta-bar { padding: 20px 14px 24px !important; }
  .hcb-btn { min-height: 56px !important; font-size: 15px !important; }
}

/* ==========================================================
   13. 히어로 영상 잘림 해소 (2026-08-30)
   원인: main.css의 .torch-video{object-fit:cover}가 넘치는 부분을 잘라냄.
        영상은 810x1440(9:16) 세로형인데 .torch-hero는 height:100vh라
        폰 화면 비율과 어긋나 위아래가 잘림.
   해결: contain으로 전체 표시 + 히어로 높이를 영상 비율에 맞춤.
   ========================================================== */
@media (max-width: 820px) {
  .torch-hero {
    width: 100% !important;
    max-width: 100vw !important;
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: 810 / 1440;
    max-height: calc(100vh - 72px) !important;
    display: block !important;
    background: #0a0c1f !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }
  .torch-video-wrap { position: absolute !important; inset: 0 !important; }
  .torch-video {
    object-fit: contain !important;   /* 잘라내지 않고 전체 표시 */
    object-position: center center !important;
    width: 100% !important;
    height: 100% !important;
  }
  /* 영상이 세로형이라 좌우 여백이 생길 수 있으므로 배경색을 영상과 동일 톤으로 */
  .torch-video-fallback { background: #0a0c1f !important; }
  /* 오버레이가 영상을 어둡게 덮지 않도록 (텍스트가 없으므로 불필요) */
  .torch-overlay { opacity: .25 !important; }
}

/* 데스크톱에서도 영상 전체가 보이도록 */
@media (min-width: 821px) {
  .torch-video { object-fit: contain !important; }
}

/* ==========================================================
   14. 우측 흰색 세로 바 제거 (2026-08-30)
   원인: 히어로에 aspect-ratio와 max-height를 함께 주면서 요소 폭이
        화면을 넘겨 가로 스크롤이 생김 → 우측에 빈 띠로 보임
   ========================================================== */
html { overflow-x: hidden !important; }
body {
  overflow-x: hidden !important;
  width: 100% !important;
  max-width: 100% !important;
  position: relative;
}
.torch-hero, .hero-cta-bar, header, footer, main, section {
  max-width: 100vw !important;
  box-sizing: border-box !important;
}
/* 가로 넘침을 일으키는 절대배치 장식 요소 차단 */
.blob { max-width: 100vw !important; }
