/* ============================================================
   HIARC — main.css
   tokens.css를 먼저 로드한 뒤 이 파일을 로드하세요.
   ============================================================ */

/* ── 리셋 / 기본 ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  position: relative;
  font-family: var(--font-base);
  font-size: var(--fs-16);
  font-weight: var(--fw-medium);
  line-height: var(--lh-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }

/* ── 컨테이너 ─────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: var(--spacing-2xl);  /* 64px — 헤더와 동일 */
}

@media (max-width: 800px) {
  .container { padding-inline: var(--spacing-20); }
}

@media (max-width: 480px) {
  .container { padding-inline: var(--spacing-md); }
}

/* ── 헤더 ─────────────────────────────────────────────────── */
/* 외곽: 풀-와이드 (배경+sticky), 1920px까지 확장 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  max-width: 1920px;
  margin-inline: auto;
  height: var(--header-height);  /* 150px */
  background: var(--color-bg);
  box-sizing: border-box;
  display: flex;
}

/* 내부 wrapper: 콘텐츠 1280px 고정 */
.site-header__inner {
  width: 100%;
  height: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding: 30px 64px 40px;
  box-sizing: border-box;
  display: flex;
  align-items: stretch;
}

.site-header .container {
  width: 100%;
  height: 100%;
  max-width: none;
  margin-inline: 0;
  padding-inline: 0;
  display: flex;
  align-items: stretch;
  justify-content: space-between;
}

/* 로고 */
.site-logo {
  display: flex;
  align-items: baseline;
  align-self: flex-end;
  text-decoration: none;
  color: var(--color-text);
  flex-shrink: 0;
}

.site-logo__hiarc {
  font-family: var(--font-base);
  font-size: 56px;
  font-weight: var(--fw-extrabold);
  line-height: 1.1;
}

.site-logo__ideas {
  font-family: var(--font-base);
  font-size: 55px;
  font-weight: var(--fw-light);
  line-height: 1.1;
}

/* 네비게이션 */
.site-nav {
  display: flex;
  align-items: center;
  align-self: flex-start;
  gap: var(--spacing-48);
}

.site-nav__link {
  font-family: var(--font-base);
  font-size: var(--fs-18);
  font-weight: var(--fw-bold);
  line-height: 1.45;
  letter-spacing: -0.09px;
  text-transform: uppercase;
  color: var(--color-text);
  text-decoration: none;
  position: relative;
  transition: color 0.15s;
}

.site-nav__link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: var(--border-base);
  background: var(--color-text);
  transition: width 0.2s ease;
}

.site-nav__link:hover::after,
.site-nav__link.is-active::after {
  width: 100%;
}

.site-nav__link.is-active {
  color: var(--color-text);
}

/* ── 드롭다운 (Exhibition 연도) ─────────────────────────────── */
.site-nav__item {
  display: flex;
  align-items: center;
  position: relative;
}

.site-nav__submenu {
  position: absolute;
  top: 100%;          /* 헤더 바로 아래 시작 */
  left: 0;
  width: 100%;        /* Exhibition 메뉴 폭과 동일 */
  margin: 0;
  /* 2px 위쪽 투명 패딩: Exhibition의 hover 언더라인이 보이도록 살짝 띄움 + hover 끊김 방지 */
  padding: 2px 0 0;
  background: transparent;
  list-style: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(2px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s 0.15s;
  z-index: 200;
}

/* 실제 메뉴 컨테이너 배경은 li에 적용 (ul의 1px 위 패딩이 투명하게 유지) */
.site-nav__submenu li {
  background: var(--color-bg);
}

.site-nav__item--has-submenu:hover .site-nav__submenu,
.site-nav__item--has-submenu:focus-within .site-nav__submenu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s;
}

.site-nav__submenu-link {
  display: block;
  padding: 4px 12px;
  font-family: var(--font-base);
  font-size: 14px;
  font-weight: var(--fw-medium);
  color: var(--color-text);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s ease;
}

.site-nav__submenu-link:hover,
.site-nav__submenu-link:focus {
  background: var(--color-text);
  color: var(--color-bg);
  outline: none;
}

/* 검색 버튼 (네비 안에 위치) */
.header-search-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text);
  padding: var(--spacing-xs);
  display: flex;
  align-items: center;
}

/* 모바일 햄버거 */
.hamburger {
  display: none;
  align-self: flex-start;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--spacing-xs);
  flex-direction: column;
  gap: 5px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text);
  transition: transform 0.2s, opacity 0.2s, width 0.2s, margin-left 0.2s;
  transform-origin: center;
}

/* 메뉴 열림 상태: 햄버거 → X
   회전(45°) 시 시각 폭이 sin(45°) ≈ 70%로 줄어들어 햄버거보다 작아 보이는 문제 보정.
   span을 √2배(31px)로 늘려서 회전 후 시각 폭이 햄버거(22px)와 동일하게 보이도록. */
.hamburger.is-open span {
  width: 31px;
  margin-left: -4.5px;  /* (31-22)/2 — 가운데 정렬 보정 */
}
.hamburger.is-open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger.is-open span:nth-child(2) {
  opacity: 0;
}
.hamburger.is-open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* ── 모바일 드로어 ────────────────────────────────────────── */
.mobile-nav {
  display: none;
  position: fixed;
  top: var(--header-height);   /* 헤더 영역은 비워두고 그 아래부터 */
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 90;                  /* 헤더(100)보다 낮게 → 헤더의 로고/햄버거 항상 노출 */
  background: #f5f5f5;          /* 헤더와 시각 구분용 연한 회색 */
  flex-direction: column;
  padding: var(--spacing-md) var(--spacing-32);
}

.mobile-nav.is-open { display: flex; }

/* 헤더에 햄버거가 X로 토글되거나 다시 클릭으로 닫히므로 자체 X 버튼은 숨김 */
.mobile-nav__close {
  display: none;
}

.mobile-nav__links {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mobile-nav__links a {
  font-size: 22px;
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  color: var(--color-text);
  letter-spacing: var(--ls-tightest);
}

/* Exhibition 아래 연도 서브 링크 (모바일) — 세로 */
.mobile-nav__sublinks {
  list-style: none;
  margin: -8px 0 0;             /* 부모 gap 일부 상쇄로 가까이 붙임 */
  padding: 0 0 0 var(--spacing-md);  /* 들여쓰기 */
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.mobile-nav__sublinks a {
  font-size: 18px;
  font-weight: var(--fw-light);
  text-transform: none;
  letter-spacing: 0;
  color: var(--color-text);
  line-height: 1.3;
}

/* ── 검색 오버레이 ────────────────────────────────────────── */
.search-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--color-bg);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl);
}

.search-overlay.is-open { display: flex; }

.search-overlay__close {
  position: absolute;
  top: var(--spacing-xl);
  right: var(--spacing-32);
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--fs-24);
  color: var(--color-text);
}

.search-overlay__form {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.search-overlay__label {
  font-size: var(--fs-12);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
}

.search-overlay__input {
  width: 100%;
  border: none;
  border-bottom: var(--border-thick) solid var(--color-border);
  padding: var(--spacing-md) 0;
  font-size: var(--fs-36);
  font-weight: var(--fw-bold);
  font-family: var(--font-base);
  background: transparent;
  color: var(--color-text);
  outline: none;
}

.search-overlay__input::placeholder {
  color: var(--color-text-muted);
}

.search-overlay__hint {
  font-size: var(--fs-12);
  color: var(--color-text-muted);
}

/* 찜 버튼 (헤더) */
.header-bookmark-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text);
  padding: var(--spacing-xs);
  display: flex;
  align-items: center;
}

.header-bookmark-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 16px;
  height: 16px;
  padding-inline: 3px;
  background: var(--color-accent);
  color: var(--color-black);
  font-size: 9px;
  font-weight: var(--fw-bold);
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
}

/* ── 찜 목록 패널 ─────────────────────────────────────────── */
.bookmark-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 360px;
  max-width: 100vw;
  height: 100%;
  z-index: 400;
  background: var(--color-bg);
  border-left: var(--border-base) solid var(--color-border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s ease;
}

.bookmark-panel.is-open {
  transform: translateX(0);
}

.bookmark-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-20) var(--spacing-32);
  border-bottom: var(--border-base) solid var(--color-border);
  flex-shrink: 0;
}

.bookmark-panel__title {
  font-size: var(--fs-14);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.bookmark-panel__close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: var(--fs-18);
  color: var(--color-text);
  padding: 4px;
  line-height: 1;
}

.bookmark-panel__body {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md) 0;
}

.bookmark-panel__empty {
  padding: var(--spacing-60) var(--spacing-32);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--fs-14);
}

/* 찜 카드 */
.bookmark-card {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-32);
  text-decoration: none;
  color: var(--color-text);
  transition: background 0.15s;
  position: relative;
}

.bookmark-card:hover {
  background: var(--color-gray-50);
}

.bookmark-card__thumb {
  width: 64px;
  height: 44px;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--color-gray-50);
}

.bookmark-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bookmark-card__no-img {
  width: 100%;
  height: 100%;
  background: var(--color-gray-50);
}

.bookmark-card__info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.bookmark-card__student {
  font-size: var(--fs-12);
  font-weight: var(--fw-semibold);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-card__title {
  font-size: var(--fs-14);
  font-weight: var(--fw-bold);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bookmark-card__remove {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: var(--fs-12);
  padding: 4px 6px;
  line-height: 1;
  transition: color 0.15s;
}

.bookmark-card__remove:hover {
  color: var(--color-text);
}

/* 찜 패널 백드롭 */
.bookmark-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 390;
  background: rgba(0,0,0,0.3);
}

.bookmark-overlay.is-visible {
  display: block;
}

/* ── 푸터 ─────────────────────────────────────────────────── */
.site-footer {
  width: 100%;
  max-width: 1920px;
  margin-inline: auto;
  margin-top: auto;
  padding-block: var(--spacing-30);
}

.site-footer__inner {
  max-width: 1280px;
  margin-inline: auto;
  padding-inline: var(--spacing-2xl);  /* 64px — 헤더와 동일 */
  border-top: var(--border-base) solid var(--color-text);
  padding-top: var(--spacing-30);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-lg);
}

.site-footer__brand {
  font-size: 14px;
  font-weight: var(--fw-bold);
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.site-footer__social {
  display: flex;
  align-items: center;
  gap: var(--spacing-20);
}

.site-footer__social a {
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}

.site-footer__social a:hover {
  opacity: 0.6;
}

/* ── 메인 콘텐츠 영역 ─────────────────────────────────────── */
.site-main {
  flex: 1;
  width: 100%;
  max-width: 1920px;
  margin-inline: auto;
}

/* ── 유틸리티 ─────────────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ── 헤더: 다크 테마 오버라이드 ──────────────────────────── */
.theme-dark .site-header {
  background-color: var(--color-bg);
  border-bottom-color: rgba(255,255,255,0.15);
}

.theme-dark .site-nav__link::after {
  background: var(--color-accent);
}

/* ── 헤더: 라이트(투명) — 배경이미지 위 화이트 헤더 ────────── */
.header-light .site-header {
  position: absolute;
  background: transparent;
}

.header-light .site-logo { color: #fff; }
.header-light .site-nav__link { color: #fff; }
.header-light .site-nav__link::after { background: #fff; }
.header-light .hamburger span { background: #fff; }
.header-light .header-search-btn { color: #fff; }
.header-light .header-bookmark-btn { color: #fff; }

/* ── 헤더 메뉴 → 햄버거 전환 (≤920px)
   로고와 메인메뉴가 가까워지며 메뉴가 가려지기 전에 햄버거로 전환 */
@media (max-width: 920px) {
  .site-nav { display: none; }
  .hamburger { display: flex; }
}

/* ── 태블릿 (≤800px) ──────────────────────────────────────── */
@media (max-width: 800px) {
  .site-header__inner {
    padding: 16px 20px;
    align-items: center;
  }

  /* 헤더 내부 container: 모바일에선 stretch가 아닌 center로 (로고/햄버거 수직 가운데) */
  .site-header .container {
    align-items: center;
  }

  /* 로고와 햄버거 둘 다 align-self 해제 (운영 동작과 동일하게 center) */
  .site-logo,
  .hamburger {
    align-self: center;
  }

  .site-logo__hiarc { font-size: 36px; }
  .site-logo__ideas { font-size: 35px; }

  .site-footer__inner {
    max-width: none;
    padding-inline: var(--spacing-20);
  }
}

/* ── 모바일 (≤480px) ──────────────────────────────────────── */
@media (max-width: 480px) {
  .site-header__inner {
    padding: 12px 16px;
  }

  .site-logo__hiarc { font-size: 30px; }
  .site-logo__ideas { font-size: 29px; }

  .site-footer__inner { padding-inline: var(--spacing-md); }

  .mobile-nav { padding-inline: var(--spacing-md); }
  .mobile-nav__links a { font-size: 18px; }
  .mobile-nav__sublinks a { font-size: 17px; }

  .search-overlay__input { font-size: var(--fs-24); }
}
