/* =========================================================================
   가정의 벗 아카이브 — 스타일시트
   -------------------------------------------------------------------------
   기준 디자인: 피그마 와이어프레임 0919 · 01 Cover Main Grid (1440px 프레임)
   글꼴 선언은 fonts.css 에 있습니다.

   목차
     1. 디자인 토큰 (색 · 글꼴 · 크기)
     2. 기본값 (리셋 · 링크 · 버튼 · 포커스)
     3. 상단 내비게이션 (GNB)
     4. 랜딩 페이지
     5. 필터 바
     6. 필터 드롭다운
     7. 이미지 그리드
     8. 상세 모달
     9. 알림창 (대분류 먼저 선택)
    10. 반응형 — 태블릿 (≤1024px)
    11. 반응형 — 모바일 (≤640px)

   큰 글씨는 화면 폭에 비례합니다: 1440px 기준 값 ÷ 1440 = vw
   예) 121px → 8.4vw
   ========================================================================= */


/* 1. 디자인 토큰 ---------------------------------------------------------- */
:root {
  --red: #FF0000;          /* 강조 · 링크 · 선택 상태 */
  --ink: #18140F;          /* 본문 글자 */
  --line: #18140F;         /* 1px 구분선 */
  --paper: #fff;           /* 배경 */
  --muted: #8A8A8A;        /* 비활성 (필터 없을 때 Reset) */
  --dropdown-bg: #F7F7F7;  /* 드롭다운 패널 */
  --dropdown-hover: #D2E3F7;

  --serif: 'Noto Serif KR', 'Nanum Myeongjo', 'AppleMyungjo', 'Batang', serif;
  --tracking: .1em;        /* 자간 10% */

  --header-height: 48px;   /* GNB 높이 (모바일 44px) */
  --filter-height: 48px;   /* 필터 바 한 칸 높이 */
}


/* 2. 기본값 --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.5;
}

/* 자간은 모든 요소가 '자기 글자 크기'의 10% 를 쓰도록 요소마다 지정합니다.
   (em 은 요소마다 다시 계산되므로 부모의 px 값을 물려받지 않습니다) */
body, body * { letter-spacing: var(--tracking); }

a { color: inherit; }
a:hover { color: var(--red); }

button, input, select { font: inherit; font-size: 1rem; }
button { cursor: pointer; }
button, a { touch-action: manipulation; }

/* 글자처럼 보이는 버튼: [Kor] [돌아가기] [OK] 등 */
button.text {
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  font: inherit;
}
button.text:hover { color: var(--red); }

/* 키보드 포커스 */
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

/* 화면에는 숨기고 화면낭독기에만 읽히는 텍스트 */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* '본문으로 이동' 건너뛰기 링크 (키보드 사용자용) */
.skip { position: absolute; top: -100px; }
.skip:focus { top: 8px; left: 8px; z-index: 10; background: var(--paper); }


/* 3. 상단 내비게이션 (GNB) ------------------------------------------------- */
header {
  position: sticky;            /* 스크롤해도 맨 위에 고정 */
  top: 0;
  z-index: 3;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
body[data-view=home] header { display: none; }   /* 랜딩 페이지에는 GNB 없음 */

.nav {
  display: flex;
  align-items: center;
  height: var(--header-height);
}

.tabs {
  display: flex;
  align-items: center;
  height: 100%;
}
.tabs a {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 16px;
  border-right: 1px solid var(--line);
  text-decoration: none;
}
.tabs a.selected {
  color: var(--red);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
}

/* 오른쪽 끝 [처음으로 돌아갑니다...] */
.home-link {
  display: flex;
  align-items: center;
  height: 100%;
  margin-left: auto;            /* 남은 공간을 왼쪽에 몰아 오른쪽 끝으로 */
  padding: 0 16px;
  border-left: 1px solid var(--line);
  text-decoration: none;
  white-space: nowrap;
}
.home-link .label-short { display: none; }   /* 모바일에서만 짧은 문구 */


/* 4. 랜딩 페이지 ---------------------------------------------------------- */
.home {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 7px 42px clamp(48px, 10vw, 140px);
}

/* 1968—2005 / 『가정의 벗』 : 121px */
.home-title {
  margin: 0;
  font-size: clamp(44px, 8.4vw, 132px);
  font-weight: 400;
  line-height: 1.7;
}

/* 428 Covers / 659 Advertisements : 제목과 같은 121px, 빨간 밑줄 */
.home-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 1.9vw 0 0;
}
.home-links a {
  color: var(--red);
  font-size: clamp(44px, 8.4vw, 132px);
  line-height: 1.39;
  white-space: nowrap;
  text-underline-offset: .09em;
  text-decoration-thickness: .04em;
}

/* 소개문(왼쪽 970px) + 언어 선택(오른쪽) */
.home-bottom {
  display: grid;
  grid-template-columns: minmax(0, 970px) auto;
  justify-content: start;
  align-items: start;
  gap: 135px;
  margin-top: clamp(80px, 18.5vw, 267px);
}
.intro {
  max-width: 970px;
  margin: 0;
  font-size: clamp(15px, 1.39vw, 20px);
  line-height: 1.7;
}
.intro-link {
  color: var(--red);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.home-language {
  color: var(--red);
  font-size: clamp(15px, 1.39vw, 20px);
  white-space: nowrap;
}
.home-language .selected { font-weight: 600; }

/* [Logo] / [Cover Archive]-[Advertisement Archive] */
.home-footer {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 11px;
  margin-top: clamp(80px, 15.7vw, 225px);
  color: var(--red);
  font-size: clamp(15px, 1.39vw, 20px);
}
.home-footer a { text-decoration: none; }


/* 5. 필터 바 -------------------------------------------------------------- */
/* 필터 바 위 118px 여백 (광고 탭에는 [Filter] 표시) */
.archive-space {
  display: flex;
  align-items: flex-end;
  height: 118px;
  padding: 0 16px 12px;
  color: var(--red);
}

.filters {
  position: sticky;             /* 스크롤해도 GNB 바로 아래에 고정 */
  top: var(--header-height);
  z-index: 2;
  display: flex;
  align-items: stretch;
  min-height: var(--filter-height);
  background: var(--paper);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

/* 칸 폭: 표지는 모두 같은 폭 */
.filter, .search, .reset { flex: 1 1 0; min-width: 0; }

/* 칸 폭: 광고는 와이어프레임 비율 (연도 · 대분류 · 중분류 · 검색 · Reset) */
body[data-view=ad] .filter:has([data-filter=year]) { flex: 0 0 auto; min-width: 6%; }
body[data-view=ad] .filter:has([data-filter=main]),
body[data-view=ad] .filter:has([data-filter=sub]),
body[data-view=ad] .search { flex: 0 0 25.7%; }

.filter {
  position: relative;           /* 드롭다운 패널의 기준 위치 */
  display: flex;
  align-items: center;
  border-right: 1px solid var(--line);
}

.search input {
  width: 100%;
  height: 100%;
  padding: 8px 16px;
  border: 0;
  outline-offset: -4px;
  background: var(--paper);
}
.search input::placeholder { color: var(--ink); opacity: 1; }

.reset {
  padding: 8px 16px;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  text-align: right;
}
.search + .reset { border-left: 1px solid var(--line); }
.reset:hover { color: var(--red); }
.reset.idle { color: var(--muted); }    /* 걸린 필터가 없을 때 회색 */


/* 6. 필터 드롭다운 -------------------------------------------------------- */
/* 회색 패널 · 마우스 올린 줄은 하늘색에 검은 테두리 · 선택값은 빨간 SemiBold */
.dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  height: 100%;
  min-height: var(--filter-height);
  padding: 8px 16px;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  text-align: left;
}
.dropdown-toggle:hover,
.dropdown.open .dropdown-toggle { color: var(--red); }
.dropdown-toggle.active { color: var(--red); font-weight: 600; }
.dropdown-toggle.active .dropdown-icon { display: none; }   /* 값을 고르면 + 숨김 */

.dropdown-value {
  display: flex;
  gap: 1.1em;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.dropdown-icon { flex: none; line-height: 1; }

.dropdown-list {
  position: absolute;
  top: calc(100% + 1px);
  left: -1px;
  z-index: 5;
  width: calc(100% + 1px);
  min-width: 100%;
  max-height: min(352px, 60vh);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  background: var(--dropdown-bg);
  border: 1px solid var(--line);
  box-shadow: 2px 2px 0 rgba(24, 20, 15, .18);
  outline: 0;
}
.dropdown-list [role=option] {
  display: flex;
  align-items: center;
  gap: 1.1em;
  min-height: var(--filter-height);
  padding: 8px 16px;
  border: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
.dropdown-list [role=option].is-active { background: var(--dropdown-hover); border-color: var(--ink); }
.dropdown-list [role=option][aria-selected=true] { color: var(--red); font-weight: 600; }
.option-code { flex: none; }   /* 정책 시기 [P2] 부분 */


/* 7. 이미지 그리드 -------------------------------------------------------- */
/* 5열 · 타일 비율 288:381 · 이미지가 칸을 꽉 채움 */
.gallery {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: stretch;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 288 / 381;
  padding: 0;
  overflow: hidden;
  background: var(--paper);
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.tile:hover { outline: 1px solid var(--red); outline-offset: -1px; }
.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--paper);
}

/* 결과가 없을 때 */
.empty { padding: 100px 24px; text-align: center; }
.empty button { color: var(--red); text-decoration: underline; }


/* 8. 상세 모달 ------------------------------------------------------------ */
/* 1440×1024 화면에서 1140×821 · 상단 44px 바에 [돌아가기] · 왼쪽 이미지 | 오른쪽 정보 */
dialog {
  padding: 0;
  border: 1px solid var(--line);
  max-height: 90vh;
  background: var(--paper);
  color: var(--ink);
}
dialog::backdrop { background: transparent; }
dialog:focus { outline: 0; }

#detail {
  width: min(1140px, 79.2vw);
  height: min(821px, 80vh);
  max-height: none;
  overflow: hidden;
}
#detail[open] { display: flex; flex-direction: column; }
#detail-content { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.dialog-bar {
  flex: none;
  display: flex;
  align-items: flex-start;
  height: 44px;
  border-bottom: 1px solid var(--line);
}
.dialog-bar button {             /* [돌아가기] : 여백 없이 모서리에 붙음 */
  color: var(--red);
  font-weight: 600;
  line-height: 1.2;
}

.detail-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 49.6% 1fr;
  min-height: 0;
}
.detail-image {
  overflow: hidden;
  background: var(--paper);
  border-right: 1px solid var(--line);
}
.detail-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;            /* 광고: 전체가 보이게 */
  object-position: center top;
}
.detail-layout[data-type=cover] .detail-image img { object-fit: cover; }   /* 표지: 칸을 채움 */

.detail-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 40px 40px 38px;
  overflow-y: auto;
}

/* 연도 96px (누르면 그 해 목록으로 이동) */
.detail-info h2 {
  margin: 0 0 24px;
  color: var(--red);
  font-size: clamp(44px, 5.9vw, 96px);
  font-weight: 400;
  line-height: 1.15;
}
.year-link {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  line-height: inherit;
  text-align: left;
}
.year-link:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: .12em;
}

/* 표지 설명글: 14px / 행간 23px / 연도와 간격 24px */
.description {
  max-width: 31em;
  margin: 0;
  font-size: 14px;
  line-height: 23px;
  white-space: pre-line;          /* 시트의 줄바꿈 유지 */
}

/* 라벨 태그: [P2] - [Woman] … / [대분류]-[가정 : 생활] … */
.label-links {
  margin-top: auto;               /* 정보 칸 맨 아래로 */
  padding-top: 40px;
  color: var(--red);
  font-size: clamp(18px, 1.67vw, 24px);
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.label-links button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--red);
  font: inherit;
  text-align: left;
}
.label-links button:hover { text-decoration: underline; text-underline-offset: 3px; }


/* 9. 알림창 (대분류 먼저 선택) ---------------------------------------------- */
.notice {
  width: auto;
  min-width: min(560px, 90vw);
  max-width: min(780px, 90vw);
  padding: 28px 24px 18px;
  text-align: center;
}
.notice p { margin: 0 0 34px; line-height: 1.6; }
.notice .notice-ok { padding: 4px 10px; color: var(--red); font-weight: 600; }
.notice .notice-ok:hover { text-decoration: underline; text-underline-offset: 3px; }


/* 10. 반응형 — 태블릿 (≤1024px) ------------------------------------------- */
@media (max-width: 1024px) {
  /* 그리드 4열 */
  .gallery { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  /* 필터 바: 한 줄에 3칸, 마지막 줄의 Reset 은 남은 폭을 채움 */
  .filters { flex-wrap: wrap; border-bottom: 0; }
  .filters > .filter,
  .filters > .search,
  .filters > .reset { flex: 0 0 33.333% !important; border-bottom: 1px solid var(--line); }
  .filters > .reset { flex-grow: 1 !important; }

  .home-bottom { grid-template-columns: minmax(0, 1fr) auto; gap: 48px; }

  #detail { width: 88vw; height: min(760px, 84vh); }
  .detail-info { padding: 28px 28px 30px; }
}


/* 11. 반응형 — 모바일 (≤640px) -------------------------------------------- */
/* 웹과 같은 무드: 1px 선 · 대괄호 세리프 라벨 · 빨간 강조 */
@media (max-width: 640px) {
  :root { --header-height: 44px; }

  /* GNB: 탭 2개 + [처음으로] 를 한 줄에 */
  .tabs { flex: 1; }
  .tabs a { flex: 1; justify-content: center; padding: 0 8px; font-size: 15px; }
  .tabs a:last-child { border-right: 0; }
  .home-link { font-size: 15px; }
  .home-link .label-long { display: none; }
  .home-link .label-short { display: inline; }

  /* 랜딩 */
  .home { padding: 28px 20px 32px; }
  .home-title { font-size: clamp(34px, 10.5vw, 56px); line-height: 1.5; }
  .home-links a { font-size: clamp(24px, 7.1vw, 46px); line-height: 1.6; text-decoration-thickness: 1px; }
  .home-bottom { grid-template-columns: 1fr; gap: 20px; margin-top: 56px; }
  .home-language { order: -1; }   /* 언어 선택을 소개문 위로 */
  .intro, .home-language, .home-footer { font-size: 15px; }
  .home-footer { margin-top: 64px; }

  /* 필터 바: 한 줄에 2칸, 검색창은 맨 아래 한 줄 전체 */
  .archive-space { height: 56px; padding: 0 14px 10px; font-size: 15px; }
  .filters > .filter,
  .filters > .search,
  .filters > .reset { flex: 0 0 50% !important; border-right: 1px solid var(--line); border-left: 0; }
  .filters > :nth-child(even) { border-right: 0; }
  .filters > .search { order: 9; flex-basis: 100% !important; border-right: 0 !important; }
  body[data-view=ad] .reset { border-right: 0; }
  .dropdown-toggle, .search input, .reset { min-height: 46px; padding: 8px 14px; font-size: 15px; }
  .reset { text-align: center; }

  /* 드롭다운: 글자 길이만큼 넓게, 오른쪽 칸은 오른쪽 정렬 */
  .dropdown-list { width: max-content; max-width: calc(100vw - 8px); }
  .filters > :nth-child(even) .dropdown-list { left: auto; right: 0; }
  .dropdown-list [role=option] { min-height: 44px; padding: 8px 14px; font-size: 15px; }

  /* 그리드 2열 */
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* 상세 모달: 전체 화면 · 이미지 아래에 정보 · [돌아가기] 바 고정 */
  #detail { width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; margin: 0; border: 0; }
  #detail-content { overflow-y: auto; }
  .dialog-bar { position: sticky; top: 0; z-index: 1; background: var(--paper); }
  .detail-layout { display: block; flex: none; }
  .detail-image { height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .detail-image img,
  .detail-layout[data-type=cover] .detail-image img { height: auto; max-height: 68vh; object-fit: contain; object-position: center; }
  .detail-info { padding: 24px 20px 32px; overflow: visible; }
  .detail-info h2 { font-size: clamp(40px, 12vw, 56px); margin-bottom: 20px; }
  .label-links { padding-top: 28px; font-size: 18px; }

  .notice { min-width: 0; width: calc(100vw - 40px); padding: 24px 18px 14px; }
}

/* 261008 랜딩 제목: 영문일 때 "Happy Home"만 이탤릭 (Noto Serif KR은 이탤릭이 없어 브라우저가 기울여 만듦) */
.home-title-name { font-style: italic; }
