/* ==========================================================
   GILEX Livestock - core.css (Ultimate v2)
   - 목표: 동작 유지(리스크 최소) + 가독성/정리(유지보수 최대)
   - Breakpoints: 1040(Compact/Tablet) / 640(Mobile)
   - NOTE:
     * 기능/페이지 전용 스타일은 public_html/assets/common/*.css
     * 메인 전용 스타일은 main.css, 서브 전용 공용은 sub.css
   Updated: 2026-01-16
========================================================== */

/* ==========================================================
   [S0] TOKENS
========================================================== */
:root {
  /* layout */
  --container: 1040px;
  --gutter: 20px;

  /* header */
  --header-h: 80px;
  --header-h-compact: 80px;
  --gnb-item-w: 170px;

  /* typography */
  --font-base: "Nanum Gothic", system-ui, -apple-system, "Segoe UI", Roboto,
    "Noto Sans KR", Arial, sans-serif;

  /* =========================
     GILEX 2026 COLOR TOKENS
     - 브랜드 팔레트(디자인팀 지정)
     - 여기만 바꾸면 전체 톤 교체 가능
  ========================= */
  --c-forest: #004d43;
  --c-teal: #006269;
  --c-cyan: #008b92;
  --c-lime: #dde57e;
  --c-bg: #eeefef;
  --c-sand: #f2f0e3;

  /* neutral (UI 필수) */
  --c-white: #ffffff;
  --c-ink: #111111;
  --c-ink-2: #333333;

  /* semantic (컴포넌트/페이지 코드는 가능한 이걸 사용) */
  --color-primary: var(--c-forest);
  --color-secondary: var(--c-teal);
  --color-accent: var(--c-cyan);
  --color-highlight: var(--c-lime);
  --color-bg: var(--c-bg);

  /* mapping */
  --header-bg: var(--c-sand);

  /* radius */
  --radius-pill: 999px;
  --radius-card: 20px;

  /* shadow */
  --shadow-quick: 0 18px 44px rgba(0, 0, 0, 0.18);
  --shadow-header: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-topbtn: 0 18px 38px rgba(0, 0, 0, 0.22);
  --shadow-drawer: -18px 0 48px rgba(0, 0, 0, 0.22);

  /* z-index scale (숫자 전쟁 방지) */
  --z-header: 9998;
  --z-dropdown: 9999;
  --z-quick: 2000;
  --z-drawer: 20000;
}

/* ==========================================================
   [S1] BASE
========================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-base);
  margin: 0 auto;
  background: var(--c-white);
  color: var(--c-ink);
}

a {
  text-decoration: none;
  color: inherit;
}

a:hover {
  text-decoration: none;
}

/* ==========================================================
   [S2] LAYOUT PRIMITIVES
========================================================== */

/* 공용 섹션 */
.sec {
  padding: 72px 0;
}

/* container(공용): .site-container / .sec-container / .header-wrap 공통화 */
.site-container,
.sec-container,
.header-wrap {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.sec-title {
  margin: 0 0 22px;
  font-size: 28px;
  font-weight: 900;
  color: var(--color-secondary);
}

/* header 전용: 높이 유지 */
.header-wrap {
  height: 100%;
}

/* ==========================================================
   [S3] HEADER (PC BASE)
========================================================== */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  z-index: var(--z-header);
  background: var(--header-bg);
  transition: height 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.header-spacer {
  height: var(--header-h);
}

/* 3분할: logo | nav(center) | tools */
.header-inner {
  display: grid;
  height: 100%;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 18px;
}

/* LEFT */
.brand {
  justify-self: start;
  display: flex;
  align-items: center;
  color: inherit;
}

.brand-logo {
  height: 20px;
  display: block;
  margin-right: 40px;
}

.brand-text {
  font-weight: 800;
  letter-spacing: 0.2px;
}

/* RIGHT */
.header-sns {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* 공통 버튼 */
.sns-btn {
  height: 34px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

/* ENG pill */
.sns-lang {
  padding: 0 12px;
  border: 2px solid var(--color-secondary);
  color: var(--color-secondary);
  background: transparent;
  font-size: 13px;
  line-height: 1;
}

/* 아이콘 원형 */
.sns-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  background: var(--color-secondary);
  border: 0;
}

.sns-icon img {
  width: 20px;
  height: 20px;
  display: block;
  object-fit: contain;
  pointer-events: none;
}

.header-tools {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* scroll 상태 */
.site-header.is-scrolled {
  height: var(--header-h-compact);
  box-shadow: var(--shadow-header);
}

.site-header.is-scrolled + .header-spacer {
  height: var(--header-h-compact);
}

/* ==========================================================
   [S4] NAV (PC)
========================================================== */

.main-nav {
  width: 100%;
  justify-self: stretch;
  position: relative;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* gap: 65px; */
}

.nav-item {
  position: relative;
  width: var(--gnb-item-w);
  display: flex;
  justify-content: center;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 18px;

  /* 폰트 원복(디자인팀 스펙) */
  font: normal normal 800 19px/30px NanumGothic, sans-serif;
  letter-spacing: 0px;
  color: var(--color-secondary);

  /* 줄바꿈/쪼개짐 방지 */
  white-space: nowrap;
  word-break: keep-all;
}

/* 모바일 토글 버튼(PC에선 숨김) */
.nav-toggle {
  display: none;
}

/* hover 시 1depth도 초록 박스로 */
.nav-item.has-sub:hover > .nav-link,
.nav-item.has-sub:focus-within > .nav-link {
  background: var(--color-secondary);
  color: var(--c-white);
}

/* ==========================================================
   [S5] SUB MENU (PC)
========================================================== */

.sub {
  list-style: none;
  margin: 0;
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  background: var(--color-secondary);
  border-radius: 0;
  box-shadow: none;
  z-index: var(--z-dropdown);
  padding: 16px 0 12px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.sub::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 44px;
  height: 1px;
  background: rgba(255, 255, 255, 0.55);
}

.sub a {
  display: block;
  padding: 10px 0;
  text-align: center;
  color: var(--c-white);
  font: normal normal 700 14px/20px NanumGothic, sans-serif;
  white-space: nowrap;
  word-break: keep-all;
}

.sub a:hover {
  background: rgba(255, 255, 255, 0.12);
}

/* 열림 */
.nav-item.has-sub:hover > .sub,
.nav-item.has-sub:focus-within > .sub {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ==========================================================
   [S5-LEGACY] DROPDOWN CLIP SAFETY
   - 템플릿 구조 다양성 때문에 범위를 넓게 둔 방어 코드
   - 추후 header 스코프로 좁히는 작업 가능(리스크 큰 변경)
========================================================== */
header,
.header,
.header-inner,
.main-header {
  overflow: visible;
  position: relative;
  z-index: var(--z-dropdown);
}

/* ==========================================================
   [S6] QUICK MENU
========================================================== */

.quick-menu {
  position: fixed;
  top: 150px;
  right: max(16px, calc((100vw - var(--container)) / 2 - 172px));
  z-index: var(--z-quick);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.quick-item {
  width: 132px;
  height: 180px;
  border-radius: var(--radius-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  font-weight: 900;
  font-size: 15px;
  line-height: 1.25;
  color: var(--c-white);
  box-shadow: var(--shadow-quick);
}

.quick-ico {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
}

.quick-ico img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.quick-txt {
  display: block;
  font-size: 14px;
  letter-spacing: -0.02em;
}

/* 색상(현재 class 유지) */
.qm-yellow {
  background: var(--color-highlight);
  color: var(--c-forest);
}

.qm-orange {
  background: var(--color-accent);
  color: var(--c-white);
}

.qm-green {
  background: var(--color-primary);
  color: var(--c-white);
}

/* ==========================================================
   [S7] FOOTER
========================================================== */

.site-footer {
  background: var(--color-secondary);
  color: rgba(255, 255, 255, 0.92);
  padding: 90px 0 70px;
}

.footer-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 40px;
}

.footer-title {
  margin: 0 0 22px;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.4px;
  color: var(--c-white);
}

.footer-meta p {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.8;
  letter-spacing: -0.1px;
  color: rgba(255, 255, 255, 0.78);
}

.btn-top {
  flex: 0 0 auto;
  width: 92px;
  height: 92px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--c-white);
  color: var(--c-ink);
  font-size: 22px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-topbtn);
}

.btn-top:hover {
  transform: translateY(-2px);
}

/* ==========================================================
   [S8] RESPONSIVE (1040 / 640)
========================================================== */

/* 1040 이하: Compact/Tablet */
@media (max-width: 1040px) {
  /* SUB MENU tone reset (Accordion 느낌) */
  .sub {
    position: static;
    background: transparent;
    padding: 6px 0 12px;
  }

  .sub a {
    color: var(--c-ink-2);
    padding: 10px 0;
  }

  .sub a:hover {
    background: transparent;
  }

  /* Quick menu: 좁은 화면에서는 컨텐츠 침범 가능성 높아 숨김 */
  .quick-menu {
    display: none;
  }

  /* Legacy: 메인 히어로(메인 전용) - 기존 동작 유지 위해 잔류 */
  .hero-inner {
    grid-template-columns: 1fr;
  }
  .hero-title {
    font-size: 64px;
  }
  .hero-title2 {
    font-size: 34px;
  }

  /* Footer compact */
  .site-footer {
    padding: 60px 0 50px;
  }

  .footer-inner {
    flex-direction: column;
    gap: 24px;
  }

  .footer-title {
    font-size: 26px;
  }

  .footer-meta p {
    font-size: 13px;
  }

  .btn-top {
    width: 74px;
    height: 74px;
    font-size: 18px;
    align-self: flex-end;
  }
}

/* 640 이하: Mobile Fine-tuning (필요 시 확장) */
@media (max-width: 640px) {
  /* intentionally blank */
}

/* ==========================================================
   [S9] MOBILE DRAWER NAV
   - 하단 패치 내역을 최종 적용본 기준으로 정리
   - PC 영향 0 (1040 이하에서만 활성)
========================================================== */

@media (max-width: 1040px) {
  :root {
    --m-drawer-w: min(86vw, 360px);
    --m-drawer-z: var(--z-drawer);

    /* 공용 테마 토큰(사이트별 오버라이드 가능) */
    --m-drawer-bg: var(--color-secondary);
    --m-drawer-sub-bg: var(--c-sand);
    --m-drawer-line: rgba(255, 255, 255, 0.3);
    --m-drawer-pad: 28px;
  }

  /* 헤더: 로고 + 햄버거만 */
  .site-header .header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    column-gap: 12px;
  }

  .site-header .header-inner > .main-nav,
  .site-header .header-inner > .header-sns {
    display: none;
  }

  .site-header .brand {
    flex: 0 1 auto;
  }

  .site-header .m-nav-btn {
    flex: 0 0 auto;
  }

  /* 햄버거 버튼 */
  .m-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
  }

  .m-nav-ico {
    position: relative;
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-secondary);
    border-radius: 2px;
  }

  .m-nav-ico::before,
  .m-nav-ico::after {
    content: "";
    position: absolute;
    left: 0;
    width: 22px;
    height: 2px;
    background: var(--color-secondary);
    border-radius: 2px;
  }

  .m-nav-ico::before {
    top: -7px;
  }

  .m-nav-ico::after {
    top: 7px;
  }

  /* 오버레이 */
  .m-nav-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--m-drawer-z);
    background: rgba(0, 0, 0, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

  /* 드로어 */
  .m-nav-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: var(--m-drawer-w);
    z-index: calc(var(--m-drawer-z) + 1);
    transform: translateX(102%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-drawer);
    overflow: hidden;
  }

  body.m-nav-open .m-nav-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  body.m-nav-open .m-nav-drawer {
    transform: translateX(0);
  }

  body.m-nav-open {
    overflow: hidden;
  }

  /* top / body / bottom */
  .m-nav-drawer .m-drawer {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--m-drawer-bg);
    color: var(--c-white);
  }

  .m-nav-drawer .m-drawer__top {
    position: relative;
    padding: var(--m-drawer-pad) var(--m-drawer-pad) 14px;
  }

  /* 상단 로고(이미지) */
  .m-nav-drawer .m-drawer__logo {
    display: block;
    width: auto;
  }

  /* 상단 텍스트(로고 없을 때만) */
  .m-nav-drawer .m-drawer__title {
    font: normal normal 900 32px/38px NanumGothic, sans-serif;
    color: var(--c-white);
    letter-spacing: -0.02em;
  }

  .m-nav-drawer .m-drawer__top::after {
    content: "";
    display: block;
    height: 1px;
    margin-top: 14px;
    background: rgba(255, 255, 255, 0.35);
  }

  .m-nav-drawer .m-drawer__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 44px;
    height: 44px;
    border: 0;
    background: transparent;
    color: var(--c-white);
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
  }

  .m-nav-drawer .m-drawer__body {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .m-nav-drawer .m-drawer__bottom {
    padding: 22px var(--m-drawer-pad) var(--m-drawer-pad);
  }

  /* NAV: 세로 */
  .m-nav-drawer .main-nav {
    display: block;
    width: 100%;
  }

  .m-nav-drawer .nav-list {
    display: block;
    margin: 0;
    padding: 0;
  }

  .m-nav-drawer .nav-item {
    width: 100%;
    display: block;
    position: relative;
    border-bottom: 0 !important; /* 외부 CSS 잔재 방어 */
  }

  /* 메뉴 구분선 */
  .m-nav-drawer .nav-item::after {
    content: "";
    display: block;
    height: 1px;
    margin: 0 var(--m-drawer-pad);
    background: var(--m-drawer-line);
  }

  .m-nav-drawer .nav-item:last-child::after {
    display: none;
  }

  /* 1-depth */
  .m-nav-drawer .nav-link {
    display: block;
    padding: 18px calc(var(--m-drawer-pad) + 24px) 18px var(--m-drawer-pad);
    color: var(--c-white);
    font: normal normal 900 18px/26px NanumGothic, sans-serif;
    background: transparent;
    cursor: pointer;
  }

  /* 화살표(토글) */
  .m-nav-drawer .nav-toggle {
    display: block;
    position: absolute;
    top: 9px;
    right: 12px;
    width: 44px;
    height: 44px;
    border: 0;
    background: transparent;
    cursor: pointer;
    transform: none !important; /* 외부 CSS 잔재 방어 */
  }

  .m-nav-drawer .nav-toggle::before {
    content: "";
    display: block;
    width: 10px;
    height: 10px;
    margin: 0 auto;
    border-right: 2px solid rgba(255, 255, 255, 0.85);
    border-bottom: 2px solid rgba(255, 255, 255, 0.85);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
  }

  .m-nav-drawer .nav-item.is-open > .nav-toggle::before {
    transform: rotate(-135deg);
  }

  /* SUB (sand) */
  .m-nav-drawer .sub {
    display: none;
    position: static;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    margin: 0;
    padding: 10px 0 14px;
    background: var(--m-drawer-sub-bg);
    box-shadow: none;
    border-radius: 0;
  }

  .m-nav-drawer .sub::before {
    display: none;
  }

  .m-nav-drawer .nav-item.is-open > .sub {
    display: block;
  }

  .m-nav-drawer .sub-link {
    display: block;
    padding: 10px var(--m-drawer-pad);
    text-align: left;
    color: var(--c-ink-2);
    font: normal normal 700 15px/22px NanumGothic, sans-serif;
  }

  .m-nav-drawer .sub-link::before {
    content: "- ";
    margin-right: 6px;
    color: var(--c-ink-2);
  }

  /* 하단(ENG/SNS) */
  .m-nav-drawer .m-drawer__bottom .header-sns {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .m-nav-drawer .m-drawer__bottom .sns-lang {
    border-color: rgba(255, 255, 255, 0.8);
    color: var(--c-white);
  }

  .m-nav-drawer .m-drawer__bottom .sns-icon {
    background: rgba(255, 255, 255, 0.16);
  }
}

/* 1041 이상: 모바일 드로어 강제 숨김 */
@media (min-width: 1041px) {
  .m-nav-btn,
  .m-nav-overlay,
  .m-nav-drawer {
    display: none !important;
  }

  body.m-nav-open {
    overflow: auto;
  }
}
