/* Global Styles - rem 단위 사용 */
/*
  반응형: 1280px, 1024px, 768px. 터치 타겟 --touch-target 44px
*/

/* 본문: EB Garamond + Pyeonsan / UI: Noto Sans KR */
@import url("https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;1,400&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700&display=swap");

@font-face {
    font-family: "Pyeonsan";
    src: url("../../fonts/pyeonsan.woff2") format("woff2");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

html,
body {
    font-family: "EB Garamond", Garamond, "Pyeonsan", serif;
    line-height: 1.3;
}

/* 편산 로드 전에는 숨김, 로드되면 표시 (FOUT 방지) - html 배경은 항상 표시 */
html {
    background: #e9e9e9;
}
html:not(.pyeonsan-loaded) body {
    visibility: hidden;
}
html.pyeonsan-loaded body {
    visibility: visible;
}

/* 버튼·클릭 UI 공통: 산세리프 + 버튼처럼 보이게 */
button,
.btn-submit,
input[type="submit"],
input[type="button"],
[class*="-trigger"],
[class*="-btn"],
.exhibition-modal-write-close {
    font-family: var(--font-ui);
    font-size: var(--font-ui-size);
    font-weight: 500;
    border-radius: var(--btn-radius);
    border: var(--border-width) solid var(--border-color);
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

:root {
    /* 반응형: 최소 14px, 1.2vw 비례, 최대 20px */
    font-size: clamp(16px, 1.2vw, 22px);

    --font-ui: "Noto Sans KR", -apple-system, BlinkMacSystemFont, sans-serif;
    --font-ui-size: 0.75rem;

    --touch-target: 44px;

    /* max 치수 (분기: 768 / 1024 / 1280) - 콘텐츠·페이지·갤러리 통일 */
    --max-container: 1920px;
    --max-content: 1200px;
    --max-modal-w: 640px;
    --max-modal-h: 90vh;
    --max-footer-legal: 36em;

    --nav-height: 3.5rem;
    
    --border-width: 1px;
    --border-color: black;
    --border: var(--border);

    /* X(닫기) 버튼 크기 공통 */
    --close-btn-size: 1.5rem;

    /* 간격 스케일 (margin, padding, gap 통일) */
    --space-1: 0.1rem;
    --space-2h: 0.2rem;
    --space-2: 0.25rem;
    --space-4h: 0.4rem;
    --space-3: 0.5rem;
    --space-4: 0.75rem;
    --space-5: 1rem;
    --space-6: 1.25rem;
    --space-7: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-page: 5rem;
    --pad-bottom-pct: 5%;
    --gap-inline: 0.15em;
    /* 패딩 별칭 (블록/버튼 공통) */
    --pad: var(--space-3);
    --pad-block: var(--space-4);
    /* 버튼·클릭 UI 공통 */
    --btn-radius: 0.375rem;
    --btn-padding-y: var(--space-3);
    --btn-padding-x: var(--space-4);

    --bg-write: #fff;
}

/* 버튼·input 등 포커스 시 블루 제거, 전부 블랙으로 통일 */
button:focus,
button:focus-visible,
input:focus,
input:focus-visible,
textarea:focus,
textarea:focus-visible,
select:focus,
select:focus-visible,
[class*="-trigger"]:focus,
[class*="-trigger"]:focus-visible,
.modal-close:focus,
.modal-close:focus-visible,
a:focus,
a:focus-visible {
    outline-color: black;
    box-shadow: none;
}
/* 터치 기기 탭 하이라이트도 블랙 */
button,
input,
textarea,
select,
a,
[role="button"] {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.15);
}

/* 전체 스크롤바 숨김 (스크롤은 가능) */
html,
body {
    scrollbar-width: none;
}
html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

body {
    letter-spacing: -0.01rem;
    background: #e9e9e9;
    padding-top: calc(var(--nav-height) + env(safe-area-inset-top, 0));
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    overflow-x: hidden;
}

/* 드래그/선택 하이라이트 - 모노톤 */
::selection {
    background: #d0d0d0;
    color: black;
}

::-moz-selection {
    background: #d0d0d0;
    color: black;
}

/* Navigation - 최상위 고정, 반응형 safe-area */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    padding-top: env(safe-area-inset-top, 0);
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
    z-index: 2147483647;
}

.nav__container {
    max-width: var(--max-container);
    margin: 0 auto;
    padding: 0 var(--pad-block);
    background: rgba(233, 233, 233, 0.75);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav__logo {
    font-size: 1.25rem;
    font-weight: bold;
    text-decoration: none;
    color: black;
    flex-shrink: 0;
    min-width: 0;
    padding: var(--space-3);
}

.nav__logo .nav__logo-ko,
.nav__logo .nav__logo-en {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav__logo .nav__logo-en {
    letter-spacing: 0.05em;
}

.nav__menu {
    display: flex;
    flex-shrink: 0;
    gap: var(--space-5);
}

.nav__link {
    color: black;
    text-decoration: none;
    white-space: nowrap;
}

/* Mobile Menu Toggle - 햄버거 SVG만 */
.nav__toggle {
    display: none;
    padding: 0;
    margin: 0;
    border: none;
    background: none;
    border-radius: 0;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.nav__toggle img {
    display: block;
    width: 24px;
    height: 24px;
}

.nav__toggle:hover img {
    opacity: 0.7;
}

/* Main Container - nav보다 아래 레이어로 두어 메뉴 클릭 가능 */
.main-container {
    display: flex;
    align-items: stretch;
    justify-content: center;
    min-height: 0;
    position: fixed;
    top: 0;
    padding-top: var(--space-5);
    z-index: 0;
}

.main-container.gallery-container {
    padding: calc(var(--nav-height) + var(--space-7)) var(--pad-block);
}

/* Artist list (shared: map, about) */
.artist-list-main {
    display: table;
    width: 100%;
    border-collapse: collapse;
}

.artist-list-main .artist-item {
    display: table-row;
    border-top: var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.artist-list-main .artist-item:hover {
    background: #f0f0f0;
}

.artist-list-main .artist-item.active {
    background: black;
}

.artist-list-main .artist-number {
    display: table-cell;
    width: 2rem;
    text-align: center;
}

.artist-list-main .artist-name {
    display: table-cell;
    font-weight: bold;
}

/* Modal - 메뉴·오버레이보다 위, 배경 포함 동일 z-index */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(240, 240, 240, 0.9);
    z-index: 2147483648; /* nav(2147483647)보다 높게 */
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
    min-height: 0; /* flex 컨테이너도 줄어들어야 내부 스크롤 가능 */
}

/* 모달: 비율 9:16, 반응형으로 뷰포트에 맞춰 빈 공간 없이 */
.modal-content {
    background: #fff;
    aspect-ratio: 9 / 16;
    width: 95%;
    max-width: var(--max-modal-w);
    max-height: var(--max-modal-h);
    min-height: 0; /* flex 자식이 줄어들어야 overflow 스크롤 생김 */
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    margin: 0;
    padding: var(--pad-block);
    z-index: 1;
    border: var(--border);
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch; /* iOS 관성 스크롤 */
    display: flex;
    flex-direction: column;
    scrollbar-width: none;
}
.modal-content::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

/* 모달 상단 1줄: 제목(왼쪽) + X(오른쪽) */
.modal-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-header-row .modal-title {
    margin: 0 0 var(--space-5) 0;
    font-weight: bold;
}

.modal-header-row .modal-header {
    margin-bottom: 0;
    padding-bottom: 0;
}

/* X(닫기) 버튼 공통: root --close-btn-size */
.modal-close {
    width: var(--close-btn-size);
    height: var(--close-btn-size);
    min-width: var(--close-btn-size);
    min-height: var(--close-btn-size);
}

/* Close: 모달 안 블랙 배경 + 흰색 X */
.modal .modal-close {
    flex-shrink: 0;
    padding: 0;
    border: none;
    border-radius: var(--btn-radius);
    background: #000;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3C/svg%3E");
    background-size: 60%;
    background-position: center;
    background-repeat: no-repeat;
    cursor: pointer;
    font-size: 0;
    text-indent: -9999px;
    overflow: hidden;
}

.modal .modal-close:hover {
    background-color: #333;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3C/svg%3E");
}

button[class*="close"]:not(.modal-close) {
    z-index: 2147483647 !important;
}

/* Close: 모달 밖(기타 페이지) close.svg */
.modal-close:not(.modal .modal-close) {
    padding: 0;
    border: var(--border-width) solid #000;
    background: #000;
    cursor: pointer;
    border-radius: var(--btn-radius);
    background-image: url(../../images/close.svg);
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    filter: brightness(0) invert(1);
    text-indent: -9999px;
    overflow: visible;
}

.modal-close:not(.modal .modal-close):hover {
    background: #fff;
    border-color: var(--border-color);
    filter: none;
}

.modal .modal-header,
.modal .modal-body {
    z-index: 0; /* close 버튼에 묻히지 않도록 항상 아래 */
}

.modal-header-title,
.modal-header .modal-title {
    font-weight: bold;
    margin-bottom: var(--space-5);
}

.form-group label {
    display: block;
    font-family: var(--font-ui);
    font-size: var(--font-ui-size);
    font-weight: 500;
    margin-bottom: var(--space-2);
}

.form-char-count {
    display: block;
    font-family: var(--font-ui);
    font-size: var(--font-ui-size);
    font-weight: 500;
    margin-top: var(--space-1);
    color: #666;
}

/* 이미지 추가 등 라벨·UI 텍스트 산세리프 통일 */
.exhibition-add-image-label,
.exhibition-add-image-label .exhibition-add-image-text,
.gallery-add-image-label,
.gallery-add-image-label .gallery-add-image-text {
    font-family: var(--font-ui);
    font-size: var(--font-ui-size);
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group input[type="file"] {
    width: 100%;
    padding: var(--pad);
    background: #fff;
    border: var(--border-width) solid var(--border-color);
    border-radius: var(--btn-radius);
    box-sizing: border-box;
    appearance: none;
}

.form-group input[type="file"] {
    cursor: pointer;
}

.form-group input[type="url"]::placeholder {
    font-style: italic;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--border-color);
    box-shadow: none;
}

.form-group input[type="file"]::-webkit-file-upload-button {
    padding: var(--btn-padding-y) var(--btn-padding-x);
    background: #000;
    color: #fff;
    border: var(--border-width) solid #000;
    border-radius: var(--btn-radius);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: var(--font-ui-size);
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.form-group input[type="file"]::-webkit-file-upload-button:hover {
    background: #fff;
    color: #000;
    border-color: var(--border-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 3rem;
    display: block;
    font-family: inherit;
}

.btn-submit {
    background: #000;
    color: #fff;
    cursor: pointer;
    padding: var(--btn-padding-y) var(--btn-padding-x);
    border: var(--border-width) solid #000;
    width: 100%;
    min-height: var(--touch-target);
}

.btn-submit:hover {
    background: #fff;
    color: #000;
    border-color: var(--border-color);
}

.btn-submit:active {
    background: #000;
    color: #fff;
}

/* About & Note Pages - 갤러리 컨테이너와 동일한 패딩, 각 페이지 상단 5rem */
.page-container {
    max-width: var(--max-content);
    margin: 0 auto;
    padding: var(--space-page) var(--pad-block);
}

.page-content .page-title {
    font-weight: bold;
    margin-bottom: var(--space-5);
    border-bottom: 2px solid var(--border-color);
}

.page-content .content-text {
    white-space: pre-wrap;
}

/* About section (shared: about, contact) - 흰색 보더 박스, 테두리만 */
.about-section {
    margin-top: var(--space-5);
    border: var(--border);
    background: white;
}

.about-section .section-title {
    font-weight: bold;
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-3);
    border-bottom: var(--border);
}

.about-section a {
    text-decoration: underline;
}

/* Site Footer - nav와 동일하게 __container로 width/패딩 반응형 */
.site-footer {
    margin-top: auto;
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
    border-top: var(--border-width) solid var(--border-color);
    background: transparent;
    text-align: left;
    font-size: 0.75rem;
}

.site-footer__container {
    max-width: var(--max-content);
    margin: 0 auto;
    padding: var(--space-5) var(--pad-block);
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    gap: 1rem;
}

.site-footer__container > * {
    min-width: 0;
}

.site-footer-legal {
    opacity: 0.9;
    max-width: var(--max-footer-legal);
}

.site-footer-legal p {
    font-size: 0.95em;
}

.site-footer-credits {
    opacity: 0.9;
    text-align: left;
}

.site-footer-credits .site-footer-credits-line {
    margin: 0 0 var(--space-1);
}

.site-footer-credits .site-footer-credits-line:last-child {
    margin-bottom: 0;
}

.site-footer-credits a {
    text-decoration: underline;
    color: black;
}

.site-footer-credits a:hover {
    opacity: 0.7;
}

/* About 전용: 저작권/크레딧을 768 이하에서만 하단에 표시, 톤 다운 */
.site-footer-copyright-mobile {
    display: none;
}

.site-footer-copy {
    opacity: 0.85;
}

.artist-list-main .artist-name-link {
    display: table-cell;
    font-weight: bold;
    text-decoration: none;
}

.artist-list-main .artist-name-link:hover {
    text-decoration: underline;
}

/* Loading & Empty */
.loading,
.empty-state {
    text-align: center;
    font-style: italic;
}

/* Links */
a {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 4px;
}

a:hover {
    text-decoration: none;
}

/* Responsive - 1280px 이하 (Tablet) */
@media (max-width: 1280px) {
    :root {
        --max-container: 100%;
        --max-content: min(1200px, 90%);
        --max-modal-w: min(640px, 95%);
        --max-modal-h: 90vh;
    }
}

/* Responsive - 1024px 이하 (Tablet narrow) */
@media (max-width: 1024px) {
    :root {
        --max-content: min(1200px, 92%);
        --max-modal-w: min(640px, 94%);
    }
}

/* Responsive - 768px 이하 (Mobile, 480 통합) */
@media (max-width: 768px) {
    :root {
        font-size: 19px;
        --nav-height: 3.75rem;
        --border-width: 1px;
        --max-content: 100%;
        --max-modal-w: min(100%, 100vw - var(--space-7));
        --max-modal-h: 90dvh;
        --max-footer-legal: none;
    }

    html,
    body {
        overflow-x: hidden;
        max-width: 100vw;
    }

    body {
        padding-top: calc(var(--nav-height) + env(safe-area-inset-top, 0));
    }

    /* Footer: 768px 이하에서 숨김 (about는 아래에서 copyright-mobile만 표시) */
    .site-footer {
        display: none !important;
    }

    /* About: 768 이하에서만 저작권/크레딧 하단 표시, 톤 다운 */
    body.page-about .site-footer-copyright-desktop {
        display: none !important;
    }
    body.page-about .site-footer-copyright-mobile {
        display: block;
        font-size: 0.7rem;
        opacity: 0.65;
        color: #555;
    }
    body.page-about .site-footer-copyright-mobile .site-footer-legal p,
    body.page-about .site-footer-copyright-mobile .site-footer-credits-line {
        margin-bottom: var(--space-1);
    }
    body.page-about .site-footer-copyright-mobile .site-footer-credits a {
        color: #555;
    }

    /* Header: 햄버거 메뉴, 로고 축소 */
    .nav {
        padding-top: env(safe-area-inset-top, 0);
    }

    .nav__container {
        flex-wrap: wrap;
    }

    .nav__logo .nav__logo-ko {
        font-size: 0.85em;
    }

    .nav__logo .nav__logo-en {
        font-size: 0.65em;
    }

    .nav__toggle {
        display: flex;
    }

    .nav__menu {
        display: none;
    }
    
    .main-container {
        align-items: center;
        padding: 0;
    }
    
    .modal-content {
        aspect-ratio: 9 / 16;
        width: 94%;
        border: var(--border-width) solid var(--border-color);
    }
    
    .btn-submit {
        min-height: var(--touch-target, 44px);
        border: var(--border-width) solid var(--border-color);
    }
    
    .page-container {
        box-sizing: border-box;
    }

    .nav__overlay-link {
        font-size: 1.25rem;
        min-height: var(--touch-target, 44px);
        display: inline-flex;
        align-items: center;
    }
}

/* 모달 열렸을 때: 네비 아래로 + 뒤 배경 스크롤 잠금 (html 포함, body fixed로 배경 스크롤 완전 차단) */
html:has(.modal.active),
html.modal-open,
body:has(.modal.active),
body.modal-open {
    overflow: hidden;
    height: 100%;
}

body:has(.modal.active),
body.modal-open {
    position: fixed;
    width: 100%;
    left: 0;
    right: 0;
    /* height는 지정하지 않음 → 콘텐츠 높이 유지, 배경 포스트가 잘리지 않고 보이도록 */
    height: auto;
    min-height: 100%;
}

body:has(.modal.active) .nav,
body.modal-open .nav {
    visibility: hidden;
    pointer-events: none;
    z-index: -1;
}

/* Nav overlay (모바일 메뉴 - 90% 흰색) */
.nav__overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: #e9e9e9;
    z-index: 10001;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.nav__overlay.active {
    display: flex;
}

.nav__overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.nav__overlay-link {
    text-decoration: none;
    color: black;
}